Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sql command, several search criteria

Author  Topic 

LiteProgrammer
Starting Member

2 Posts

Posted - 2013-12-04 : 08:51:28
Hi,

I am very new to sql programming. I have a database with 15 columns. At this moment I do this to get all rows containing the year 2013: WHERE DATEPART(yyyy, DownloadDate) = 2013
. But I also want to add a criteria so that I can have all rows where DownloadDate contains 2013 AND WHERE IsRead(BIT) contains NULL. I tried this: WHERE DATEPART(yyyy, DownloadDate) = 2013 AND IsRead = null
. But this gave me nothing!

Thx for help

NeedHelp

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-12-04 : 08:55:19
use "isRead IS NULL" instead of "= null"

Cheers
MIK
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-04 : 09:47:14
also make the data filter condition as

DownloadDate > = '20130101' AND DownloadDate < '20140101'


if you want to make use of an existing index on it

see
http://visakhm.blogspot.com/2012/12/different-ways-to-implement-date-range.html



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

LiteProgrammer
Starting Member

2 Posts

Posted - 2013-12-05 : 08:22:22
Thanks for all your help. It worked like magic :)
Go to Top of Page
   

- Advertisement -