SET IDENTITY_INSERT  #tmp ON
再执行过程

解决方案 »

  1.   

    SET IDENTITY_INSERT  #tmp ON
        insert into #tmp(id , name )
         value(-999, 'abc')
    SET IDENTITY_INSERT  #tmp OFF
      

  2.   

    楼上的朋友, #tmp是 在该存储过程中创建的, 如你所说, 是有问题的!
      

  3.   

    回复人: zjcxc(邹建) ( ) 信誉:405  2004-10-22 21:46:00  得分: 0  
     
     
       SET IDENTITY_INSERT  #tmp ON
        insert into #tmp(id , name )
         value(-999, 'abc')
    SET IDENTITY_INSERT  #tmp OFF
      
     
    朋友, 我那样也试过了, 还是有同样的错误!
      

  4.   

    我觉得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
    --把它放在过程外,是可以执行的
      

  5.   

    我想了一个变通的方法:
       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也报错, 是不是临时表是不能修改表结构的?