5

Is it possible to create a table with a column that has type DATETIME and give it a default value such as CURRENT_TIMESTAMP or GETDATE()? Is there another way to do this?

Screenshot from SSMS 2017

Screenshot

Andrea
  • 11,801
  • 17
  • 65
  • 72
r3dfarce
  • 161
  • 1
  • 2
  • 9
  • 1
    use SYSDATETIME() and define your field as DATETIME2(7): it's way more accurate than DATETIME and GETDATE() – Bestter Jul 23 '18 at 19:47

1 Answers1

9

Define a constraint using TSQL:

ALTER TABLE TableName ADD CONSTRAINT DF_TableName DEFAULT GETDATE() FOR ColumnName
Andrea
  • 11,801
  • 17
  • 65
  • 72