您的位置:程序门 -> ms-sql server -> 基础类



从表a插入记录到表b,出现错误,请帮忙!


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


从表a插入记录到表b,出现错误,请帮忙![已结贴,结贴人:ihq2008]
发表于:2007-07-27 11:58:25 楼主
(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不为空!
发表于:2007-07-27 12:03:411楼 得分:0
tempconrecled1     是不是为空呢?   你是不是要把conrecled中所有的数据导过去?
发表于:2007-07-27 12:04:152楼 得分:20
你的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
发表于:2007-07-27 12:07:523楼 得分:0
两种办法你都可以试一下,如果你的conrecled表为空的话可以按下边方式操作就可以:
set   identity_insert   conrecled   on
go
insert   conrecled   select   *   from   tempconrecled1
go
set   identity_insert   conrecled   off
发表于:2007-07-27 12:16:074楼 得分:0
--不为空的话去掉下边语句中的自增列再执行

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
发表于:2007-07-27 12:47:075楼 得分:0
谢谢simonhehe(收购猩猩)


快速检索

最新资讯
热门点击