How do I drop table variables in SQL-Server? Should I even do this?

前端 未结 7 1938
执笔经年
执笔经年 2020-12-12 18:58

I have a table variable in a script (not a stored procedure). Two questions:

  1. How do I drop the table variable? Drop Table @varName gives an \"Incorrect snyta
7条回答
  •  借酒劲吻你
    2020-12-12 19:23

    Table variables are just like int or varchar variables.

    You don't need to drop them. They have the same scope rules as int or varchar variables

    The scope of a variable is the range of Transact-SQL statements that can reference the variable. The scope of a variable lasts from the point it is declared until the end of the batch or stored procedure in which it is declared.

提交回复
热议问题