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
 CONDITION

Author  Topic 

sadbjp
INNER JOIN

41 Posts

Posted - 2007-04-25 : 11:57:27
Hi,I want to write a SQL stmt.(condition) that checks the following @ActionPLanID > 0 and ActionPlanID exists in table A simultaneously?

I was thinking of using IF NOT exists but don't know how to write it. Am I going in the right direction?

Thanks,
VBJP

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-25 : 12:02:54
Yes you can use IF EXISTS or IF NOT EXISTS based on your requirement:

IF NOT EXISTS(Select * from table where ActionPlanID = @ActionPLanID and @ActionPLanID > 0)
Begin
-- do something here
End


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

sadbjp
INNER JOIN

41 Posts

Posted - 2007-04-25 : 16:49:18
Thanks for the guidance !
Go to Top of Page
   

- Advertisement -