今天想插入数据从另一个表中,结果出现了各种问题
这个百度找的:insert into b(id,title,content) select id,title,content from a
这个是一开始写的:
insert into 表B select * from 表A(这样会报标识列错误信息。)
set IDENTITY_INSERT 表A on
解决方法:
set IDENTITY_INSERT 表A OFF
set IDENTITY_INSERT 表B OFF
最后的正确语句:
insert into 表B(CardNo,[PassWord],TrueName,Sex,Email,Property,Crops,PlantingArea,UseDrugs,Remark,TypeStatus,TgID,Telphone,UserID,CreateTime,[Address],Province,City,Area,Culture)
select CardNo,[PassWord],TrueName,Sex,Email,Property,Crops,PlantingArea,UseDrugs,Remark,TypeStatus,TgID,Telphone,UserID,CreateTime,[Address],Province,City,Area,Culture
from 表A
时间: 2024-10-11 14:09:20