Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear friends,

i have been trying to check in a datetime field in sql sever 2005 express whether this field is null. I tried various combination like-

"SELECT UserID FROM dbo.tblLogIn WHERE LogoutTime="

"SELECT UserID FROM dbo.tblLogIn WHERE LogoutTime="""

"SELECT UserID FROM dbo.tblLogIn WHERE LogoutTime=" & dbnull.value & ""

and many more..

but getting no result.

any idea?

SKPaul
Posted

SQL
SELECT UserID FROM dbo.tblLogIn WHERE LogoutTime IS NULL
 
Share this answer
 
v3
Comments
Simon_Whale 26-May-11 8:50am    
you have to do a "is null" when comparing null values else it wont return anything in sql server.
Kim Togo 26-May-11 8:51am    
Thanks :-)
try

SQL
SELECT UserId FROM dbotblLogin WHERE LogoutTime is null
 
Share this answer
 
Comments
Saumitra Kumar Paul 26-May-11 8:46am    
WoW, it works, Thanks a lot.
Simon_Whale 26-May-11 8:47am    
your welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900