ID列为int自动增长,现在要把表导入另外的数据库,如果新导入的表ID也自动增长则数据导不进去,如果解决?

解决方案 »

  1.   

    set identity_insert ID On
    在插入语句前面加
      

  2.   

    那是因为有重复的id值记录你是要增量呢还是覆盖?
    增量会麻烦些
    覆盖的话就先用truncate table tb1 表记录清后再导就ok了
      

  3.   


    --给你个例子
    --强制在表中插入标识值
    SET IDENTITY_INSERT 表名 ON
    INSERT tb(id,col) VALUES(10,1)
    SET IDENTITY_INSERT 表名 OFF
      

  4.   

    1.先去掉自增长属性,
    2.新增完成后,
    3.在开启自增长属性.
    借楼上的例子 :)SET IDENTITY_INSERT 表名 OFF
    INSERT tb(id,col) VALUES(10,1)
    SET IDENTITY_INSERT 表名 ON
      

  5.   

    if object_id('tb1')is not null
       drop table tb1
    go
    create  table tb1(id  int identity(1,1),Name varchar(10))
    insert tb1 select 'Stone'
    insert tb1 select 'Happy'
    insert tb1 select 'Rick'
    go
    set identity_insert tb1 on
    insert tb1(id,name) values( 10,'Stone') 
    set identity_insert tb1 off
    insert tb1 select 'Rick'
    select * from tb1