Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add default value for time(7) field

Tags:

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.

like image 840
Adnan M. TÜRKEN Avatar asked Jan 24 '11 09:01

Adnan M. TÜRKEN


People also ask

How do I get the default time in SQL?

SQL Server GETDATE() Function The GETDATE() function returns the current database system date and time, in a 'YYYY-MM-DD hh:mm:ss.


1 Answers

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.

like image 73
marc_s Avatar answered Oct 21 '22 15:10

marc_s