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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Verify Where only if not null

Author  Topic 

mike13
Posting Yak Master

219 Posts

Posted - 2013-03-13 : 01:46:37
Hi all,

i got this statement

SELECT @couponID=id,@value=value, @percent=[percent]
FROM T_Order_Coupon
WHERE (active = 1) and siteid=@siteid and coupon=@coupon AND expdate<=GETDATE()

But i only want to use the where clause expdate<=GETDATE()
if column expdate is not NULL

How do i do that?

thanks a lot,

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-13 : 01:53:21
[code]
SELECT @couponID=id,@value=value, @percent=[percent]
FROM T_Order_Coupon
WHERE (active = 1) and siteid=@siteid and coupon=@coupon AND (expdate<=GETDATE() or expdate is null)
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mike13
Posting Yak Master

219 Posts

Posted - 2013-03-13 : 05:13:00
Thanks a lot!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-13 : 06:41:25
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -