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
------解决方案--------------------
declare @tablenaem varchar(100)
set @tablename='test1'
exec ('set identity_insert' + @tablename + 'on')