cross
SSCommitted
Points: 1735
More actions
December 11, 2003 at 2:56 pm
#83098
Is there a way I can put a table name into a variable and pass it to a command? As it is the command doesn't accept the variable.
Example
declare @mytablename varchar(50)
set @mytablename = 'MyTable1'
DROP TABLE @mytablename
noeld
SSC Guru
Points: 96590
December 11, 2003 at 3:00 pm
#485854
set @mytablename = 'T'
Exec ('DROP TABLE ' + @mytablename)
* Noel
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply