r3dfarce
r3dfarce

Reputation: 181

Default Value for DATETIME column in SQL Server Management Studio 2017

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

Upvotes: 5

Views: 27211

Answers (1)

Andrea
Andrea

Reputation: 12405

Define a constraint using TSQL:

ALTER TABLE TableName ADD CONSTRAINT DF_TableName DEFAULT GETDATE() FOR ColumnName

Upvotes: 9

Related Questions