Re: Date and Null



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

.