Yes it can be done by using dynamic SQL.
Here is a simple example:
declare @tablename varchar(20)
declare @criteria varchar(500)
set @tablename = 'table1'
set @criteria = '' --you can set criteria if you wish, I'm leaving it blank, but using it in the command.
declare @command varchar(2000)
set @command = 'delete from ' + @tablename + ' ' + @criteria
exec(@command)
You can read more about execute here: http://msdn.microsoft.com/en-us/library/ms188332.aspx
adam_k
Practically a Posting Shark
803 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149