Adnan M. TURKEN
Adnan M. TURKEN

Reputation: 1594

Add default value for time(7) field

How can I add a default value for time(7) field in SQL Server ?

I tried to set "00:00:00" to "default value or binding" in SQL Server Management Studio but it didn't work.

Upvotes: 24

Views: 27247

Answers (1)

marc_s
marc_s

Reputation: 754408

Use this T-SQL statement in SSMS:

ALTER TABLE dbo.YourTable
ADD CONSTRAINT DF_TimeDefault DEFAULT '00:00:00' FOR YourTimeColumn

If you want to use the visual table designer, use this notation:

enter image description here

Put your time into single quotes, and put brackets around the value.

Upvotes: 43

Related Questions