Passing a variable to the drop table cmd

  • 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

  • declare @mytablename varchar(50)

    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