天天看点

【问】做全部数据下载时提示“违反了 PRIMARY KEY 约束 ‘PK_T_BD_ITEM_INFO‘。不能在对象 ‘t_bd_item_info‘ 中插入重复键。

【问题描述】

做全部数据下载时提示“违反了 PRIMARY KEY 约束 'PK_T_BD_ITEM_INFO'。不能在对象 't_bd_item_info' 中插入重复键。

【答】

修复门店的自增列即可。

use isszmv8_branch 

go

declare @tablename varchar(100)

declare  test_cur cursor for

select object_name(id) from syscolumns

where status=128

open test_cur

fetch test_cur into @tablename

while @@fetch_status=0

begin  

   DBCC CHECKIDENT (@tablename, RESEED)  

   fetch test_cur into @tablename

end

close test_cur

deallocate test_cur

go

继续阅读