日期:2014-05-19  浏览次数:20414 次

从表A插入记录到表B,出现错误,请帮忙!
(1)INSERT   conrecled   SELECT   *   FROM   tempconrecled1

服务器:   消息   8101,级别   16,状态   1,行   1
仅当使用了列的列表,并且   IDENTITY_INSERT   为   ON   时,才能在表   'conrecled '   中为标识列指定显式值。
(2)INSERT   into   conrecled
SELECT   id,concardno,peono,peoname,peocompany,peoshiyebu,
condate,conmoney,fundmoney,consurplus,cardconcount,contype,
contermno,contermname,conbuilding,condept,conoperno,
conopername,operno,opername,loginusername,computername,conflag  
FROM   tempconrecled1

服务器:   消息   8101,级别   16,状态   1,行   1
仅当使用了列的列表,并且   IDENTITY_INSERT   为   ON   时,才能在表   'conrecled '   中为标识列指定显式值。


注明:表conrecled和tempconrecled1表结构一致,表字段有时间字段,文本字段,money字段

表conrecled不为空!


------解决方案--------------------
你的conrecled 表中有自增字段!
解决办法,
1 如果要导入自增字段的话呢就先执行:
set IDENTITY_INSERT ON
然后再 插入
2 写出要插入的字段名称,再插入,其中,来字段列中去掉自增字段
INSERT into conrecled(id,concardno,peono,peoname,peocompany,peoshiyebu,
condate,conmoney,fundmoney,consurplus,cardconcount,contype,
contermno,contermname,conbuilding,condept,conoperno,
conopername,operno,opername,loginusername,computername,conflag)
SELECT id,concardno,peono,peoname,peocompany,peoshiyebu,
condate,conmoney,fundmoney,consurplus,cardconcount,contype,
contermno,contermname,conbuilding,condept,conoperno,
conopername,operno,opername,loginusername,computername,conflag
FROM tempconrecled1