July 28, 2008 at 2:08 pm
How can I used this code? It doesnt seem to like the @TABLE_NAME Variable..
WHILE @COUNTER < (SELECT MAX(ID) FROM #TABLE_LIST)
BEGIN
SET @COUNTER = @COUNTER + 1
SET @TABLE_NAME = (SELECT TABLE_NAME FROM #TABLE_LIST WHERE ID = @COUNTER)
DROP TABLE @TABLE_NAME
END
July 28, 2008 at 2:18 pm
You cannot use variables for column names, table names, etc... In order to do what you want you would need to use dynamic SQL.
Set @sql = 'Drop Table ' + @table_name
Exec (@sql)
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
July 28, 2008 at 2:26 pm
Awesome.... worked out!
Thanks a lot.. just need to know what to google to look for examples.
Alex
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply