我想從B服務器的A服務器中的表中插入數據。標識插入幾條記錄而不截斷到現有表
例如:
select count(*) from A.table
-- 100 rows affected
delete from A.table where customer_code = '100'
-- 10 rows affected
select count(*) from B.table
-- 200 rows affected
select count(*) from B.table where customer_code='100'
-- 20 rows affected
both the tables have identity(1,1) and primary_key
insert into A.table(customer_key,customer_code,custome_name)
select customer_key,customer_code,custome_name
from B.table where customer_code='100'
PRIMARY KEY約束--Violation。不能在對象'A.table'中插入重複鍵。
我已經嘗試
SET IDENTITY_INSERT <> ON
DBCC CHECKIDENT(<>, RESEED,0)
我使用的是SQL Server 2005中
東西必須在這裏給。您可能需要刪除'A..Customer'表上的所有數據並從頭開始重新插入(在這種情況下,您最好放棄'A..Customer'上的標識,因爲它是從'B'驅動的)否則你需要承認不可能將數據合併到'A'中,並且保留'B'的代理id的值與'A'的密鑰相同,除非你將PK放在A上並允許重複。 – StuartLC