当要插入的这个表中有自增列时,要往这个表中自增列插入数据时,系统就会报这个错,因为自增列默认不可编辑。

需要执行

set identity_insert   表名  ON

然后执行Insert语句

insert into  表1  select  * from   表2

 

在执行这句时,好像轻量的sql   sql express 中执行时 依然会报 identity_insert  没有设置成为 ON。

 

可以试一下 把具体的列都写出来

(我试的时候不再提示identity_insert  没有设置成为 ON。但是又出现约束了,必须去掉约束,我就没有再试,我觉得既然不再提示同样的错误应该是可以了)

insert into 表1 (‘列1’,‘列2’)  select  * from   表2

 

 

 

相关文章:

  • 2021-12-25
  • 2022-02-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
  • 2021-10-01
猜你喜欢
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2022-01-15
  • 2021-06-20
相关资源
相似解决方案