SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sql command, several search criteria
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

LiteProgrammer
Starting Member

Norway
2 Posts

Posted - 12/04/2013 :  08:51:28  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Pakistan
1052 Posts

Posted - 12/04/2013 :  08:55:19  Show Profile  Reply with Quote
use "isRead IS NULL" instead of "= null"

Cheers
MIK
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 12/04/2013 :  09:47:14  Show Profile  Reply with Quote
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

Norway
2 Posts

Posted - 12/05/2013 :  08:22:22  Show Profile  Reply with Quote
Thanks for all your help. It worked like magic :)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000