Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2002
    Posts
    10

    Unanswered: automatic code for each table - don't work

    Hi,
    i'm trying to automatize some tasks for each table, but this piece of code doesn't work :
    ....
    DECLARE @TableName sysname
    ...
    drop table @TableName ( or whatever ... )
    ...
    ...

    the error message is: " Incorrect syntax near '@TableName' "


    Thanks !

  2. #2
    Join Date
    Dec 2001
    Location
    Toronto, Canada
    Posts
    335
    Try using EXECUTE command:

    DECLARE @TableName sysname

    exec ('drop table ' + @TableName )
    MCDBA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •