問題現(xiàn)象:用友暢捷通T+財(cái)務(wù)軟件升級(jí)報(bào)錯(cuò),具體提示如下:腳本: 11.600.000.0000 DATA_DATA_RAP_NL 出錯(cuò):因?yàn)榘l(fā)現(xiàn)對(duì)象名稱 'dbo.EAP_VoucherDraft' 和索引名稱 'pk_EAP_VoucherDraft' 有重復(fù)的鍵,所以 CREATE UNIQUE INDEX 語句終止。重復(fù)的鍵值為 (21fdb25a-952b-f9a0-6169-e271dd0edb16)。

無法創(chuàng)建約束。

解決方案:根據(jù)重復(fù)的鍵值,查詢到重復(fù)的記錄,然后刪除重復(fù)記錄,(操作前請備份好您用友T+財(cái)務(wù)軟件中的數(shù)據(jù),可參考教程:http://bainianle.cn/jcufida/1389.html),示例語句如下:

delete from EAP_VoucherDraft where ID='21fdb25a-952b-f9a0-6169-e271dd0edb16' and Code='2014-10-15-0002'

if((select COUNT(ts) from EAP_VoucherDraft where ID='27f8bc75-a7e1-d6f9-e867-e27b87c5e7a4')>1)

begin

delete from EAP_VoucherDraft

where ID='27f8bc75-a7e1-d6f9-e867-e27b87c5e7a4'

and ts in (select top 1 ts from EAP_VoucherDraft where ID='27f8bc75-a7e1-d6f9-e867-e27b87c5e7a4')

end

if((select COUNT(ts) from EAP_VoucherDraft where ID='186EB51E-5B8A-CA28-8546-F9B9527A9ED7')>1)

begin

delete from EAP_VoucherDraft

where ID='186EB51E-5B8A-CA28-8546-F9B9527A9ED7'

and ts in (select top 1 ts from EAP_VoucherDraft where ID='186EB51E-5B8A-CA28-8546-F9B9527A9ED7')

End

執(zhí)行這個(gè):

delete from EAP_VoucherDraft

where ID in (select ID from EAP_VoucherDraft group by ID having count(ID) > 1)