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 2000 Forums
 Transact-SQL (2000)
 A small help with 'EXISTS'

Author  Topic 

zeeshan13
Constraint Violating Yak Guru

347 Posts

Posted - 2007-06-26 : 17:04:03
Look at this T-SQl Script:


IF EXISTS (SELECT ImportSID FROM Table1)
print 'EXISTS'
else
print 'Dont EXISTS'


What if I dont want anything to happen if it doesn't exists, does the following make sense?


IF EXISTS (SELECT ImportSID FROM Table1)
print 'EXISTS'



Please let me know.


tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-06-26 : 17:15:49
I'm going to take a leap of faith here and assume you at least tried it in Query Analyzer first! Does it produce the expected result?

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -