insert into a表 select * from b表 不行! == a, b表結構一樣嗎?
表结构完全一样,我用的是SQL server 2005
select * into a表 from b表
insert into a(字段1,字段2,字段n) select 字段1,字段2,字段n from b 字段都写上看看, 另外看看表中是否有自动增长字段、计算字段,若有的话,将这些字段在上边的语句中去掉。 还有表中是否有主键,新插入的数据是否违反主键要求,或与已有数据冲突。 若上边的问题都排除了,还有问题,那我就不知道了
谢谢,问题已解决,还有就是两个不同库之间,表导入数据怎么导! insert into [HealthTest100].[dbo].[Region] select * from [HealthTest].[dbo].[Region] 这样么
Msg 2627, Level 14, State 1, Line 1 Violation of PRIMARY KEY constraint 'PK_Location'. Cannot insert duplicate key in object 'dbo.Region'. The statement has been terminated.报的这个错!
==
a, b表結構一樣嗎?
a(字段1,字段2,字段n)
select
字段1,字段2,字段n
from
b
字段都写上看看,
另外看看表中是否有自动增长字段、计算字段,若有的话,将这些字段在上边的语句中去掉。
还有表中是否有主键,新插入的数据是否违反主键要求,或与已有数据冲突。
若上边的问题都排除了,还有问题,那我就不知道了
谢谢,问题已解决,还有就是两个不同库之间,表导入数据怎么导! insert into [HealthTest100].[dbo].[Region] select * from [HealthTest].[dbo].[Region] 这样么
Violation of PRIMARY KEY constraint 'PK_Location'. Cannot insert duplicate key in object 'dbo.Region'.
The statement has been terminated.报的这个错!