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 2005 Forums
 Transact-SQL (2005)
 Select statement if condition

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2010-05-18 : 14:36:49
How to write an if statement using the following select?

select TOP 1 DocumentID from TAB_ccsNetDMRevision where RevID=@revID
based on result:
if null or zero then SET @IsRevDOC = 0;

Else SET @IsRevDOC = 1;

Thank you very much for the helpful info.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-18 : 14:42:02
select TOP 1 @IsRevDOC = CASE WHEN DocumentID IS NULL OR DocumentID = 0 THEN 0 ELSE 1 END
from TAB_ccsNetDMRevision
where RevID=@revID

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -