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)
 if not exist (exec (@sql))

Author  Topic 

tpiazza55
Posting Yak Master

162 Posts

Posted - 2010-10-29 : 16:22:22
I have a dynamically built sql statement.

I need to know when executed if it returns any results. if not I need to execute another sql statement.

trying

IF NOT EXISTS ( EXEC(@SQLStatement) )
Begin
EXEC(@SQLStatement)

i get an error on the exec -- how do i get around this?

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-10-29 : 16:31:09
duplicate
see
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=152328

Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -