Re: Date and Null
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Thu, 3 Sep 2009 21:51:17 +0000 (UTC)
shapper (mdmoura@xxxxxxxxx) writes:
On my Users table I have a column named LastLock.
This column holds the last date where the account was locked.
The problem is that some users where never locked.
So I suppose I should use null for this column correct?
That would be my choice of design.
And in my C# code can I check if a SQL table column of type date is
null?
Yes, just like for any other data type.
Or is there a specific Date for not defined dates?
You can define your own magic date, but if you then mess up on
which date that was, you will have a problem. The advantage of NULL
is exactly that: it's easy to remember.
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- References:
- Date and Null
- From: shapper
- Date and Null
- Prev by Date: Re: Combine Multiple Rows single column into multiple column singl
- Next by Date: Re: Combine Multiple Rows single column into multiple column single ro
- Previous by thread: Re: Date and Null
- Index(es):
Relevant Pages
|