SET IDENTITY_INSERT #tmp ON insert into #tmp(id , name ) value(-999, 'abc') SET IDENTITY_INSERT #tmp OFF
朋友, 我那样也试过了, 还是有同样的错误!
我觉得set identity_insert #t on是不是不能入在过程中执行,你看一下我的这个语句create proc test as set identity_insert #t on insert #t (ID,con) --字段一定要填写 values(3,4) set identity_insert #t offcreate table #t(id int identity(1,1),con int) insert into #t select 1,2 set identity_insert #t on exec test --把它放在过程外,是可以执行的
我想了一个变通的方法: select identity(int, 1, 1) as a, name, 0 as b into #t from list
update #t set b = a alter table #t drop column a也报错, 是不是临时表是不能修改表结构的?
insert into #tmp(id , name )
value(-999, 'abc')
SET IDENTITY_INSERT #tmp OFF
SET IDENTITY_INSERT #tmp ON
insert into #tmp(id , name )
value(-999, 'abc')
SET IDENTITY_INSERT #tmp OFF
朋友, 我那样也试过了, 还是有同样的错误!
as
set identity_insert #t on
insert #t (ID,con) --字段一定要填写
values(3,4)
set identity_insert #t offcreate table #t(id int identity(1,1),con int)
insert into #t select 1,2
set identity_insert #t on
exec test
--把它放在过程外,是可以执行的
select identity(int, 1, 1) as a, name, 0 as b
into #t
from list
update #t
set b = a alter table #t
drop column a也报错, 是不是临时表是不能修改表结构的?