变量代替表名问题 set identity_insert 表名 on
declare @tablenaem varchar(100)
set @tablename='test1'
set identity_insert @tablename on
执行时报错 变量? identity_insert
[解决办法]
DECLARE @sql NVARCHAR(4000)
DELCARE @tablename varchar(100)
SET @sql='SET IDENTITY_INSERT '+@TABLENAME +' ON'
EXEC sp_executesql @sql