declare @name varchar(50)
[email protected]
[email protected]?
drop table @name --这样写是错误的,正确的应该怎么写?
------解决方案--------------------
- SQL code
--拼成字符串执行就可以了DECLARE @SQL ......declare @name varchar(50)SET @SQL='DROP TABLE '+...
------解决方案--------------------
- SQL code
exec('drop table [email protected])
------解决方案--------------------
- SQL code
declare @name varchar(50)set @name='tableName'exec ('drop table [email protected])
------解决方案--------------------
只能拼接成SQL语句,用EXEC执行了
------解决方案--------------------
动态获取值,请使用动态SQL。