开发者

Date datatype for SQL Server 2005

开发者 https://www.devze.com 2023-03-20 11:52 出处:网络
I am using SQL Server 2005 Express Edition. I want to store date of birth in a table, which datatype should I开发者_开发问答 use for that?

I am using SQL Server 2005 Express Edition. I want to store date of birth in a table, which datatype should I开发者_开发问答 use for that?

Datetime provides time also with the date.

Is there any way in SQL Server 2005 to store only date?


Use smalldatetime (4 bytes storage) and add a check constraint. Do not use char or such.

The CHECK CONSTRAINT would be this, based on this question Best approach to remove time part of datetime in SQL Server

DOBCol = DATEADD(day, DATEDIFF(day, 0, DOBCol), 0)
0

精彩评论

暂无评论...
验证码 换一张
取 消