Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Execute a varchar string variable?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00434888
Message ID:
00434902
Views:
12
Are you looking for something like this:

DECLARE @cmd varchar(2000)
SET @cmd = 'SELECT COUNT(*) FROM x'
EXECUTE (@cmd)

I've not directly tried it but I can't think of any reason why it wouldn't work. There are something that you need to be aware of. The statement is considered another batch. It doesn't have access to any of the variables within the calling batch. I'm also not sure if you would be able to access the Inserted and Deleted tables.

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform