問題現(xiàn)象:用友暢捷通T+財(cái)務(wù)軟件升級(jí)報(bào)錯(cuò),具體提示如下:因?yàn)榘l(fā)現(xiàn)對(duì)象名稱 'dbo.GL_ReferenceDocClass' 和索引名稱 'ix_code' 有重復(fù)的鍵,
重復(fù)數(shù)據(jù)問題SQL 腳本: 11.510.000.0000 DATA_DSTR_FI_Vou_NL.sql 出錯(cuò):因?yàn)榘l(fā)現(xiàn)對(duì)象名稱 'dbo.GL_ReferenceDocClass' 和索引名稱 'ix_code' 有重復(fù)的鍵,所以 CREATE UNIQUE INDEX 語句終止。重復(fù)的鍵值為 (01)。語句已終止。
解決辦法:根據(jù)重復(fù)的鍵值,找到重復(fù)的記錄,然后刪除(操作前請(qǐng)備份好您用友T+財(cái)務(wù)軟件中的數(shù)據(jù),可參考教程:http://bainianle.cn/jcufida/1389.html),示例語句如下:
if((select COUNT(code) from GL_ReferenceDocClass where code ='01')>1)
begin
delete from GL_ReferenceDocClass where code ='01' and ts in
(select top 1 ts from GL_ReferenceDocClass where code ='01')
end
if((select COUNT(code) from GL_ReferenceDocClass where code ='02')>1)
begin
delete from GL_ReferenceDocClass where code ='02' and ts in
(select top 1 ts from GL_ReferenceDocClass where code ='02')
end
if((select COUNT(code) from GL_ReferenceDocClass where code ='03')>1)
begin
delete from GL_ReferenceDocClass where code ='03' and ts in
(select top 1 ts from GL_ReferenceDocClass where code ='03')
end
if((select COUNT(code) from GL_ReferenceDocClass where code ='04')>1)
begin
delete from GL_ReferenceDocClass where code ='04' and ts in
(select top 1 ts from GL_ReferenceDocClass where code ='04')
end
if((select COUNT(code) from GL_ReferenceDocClass where code ='05')>1)
begin
delete from GL_ReferenceDocClass where code ='05' and ts in
(select top 1 ts from GL_ReferenceDocClass where code ='05')
end
if((select COUNT(code) from GL_ReferenceDocClass where code ='06')>1)
begin
delete from GL_ReferenceDocClass where code ='06' and ts in
(select top 1 ts from GL_ReferenceDocClass where code ='06')
end
if((select COUNT(code) from GL_ReferenceDocClass where code ='07')>1)
begin
delete from GL_ReferenceDocClass where code ='07' and ts in
(select top 1 ts from GL_ReferenceDocClass where code ='07')
end
if((select COUNT(code) from GL_ReferenceDocClass where code ='08')>1)
begin
delete from GL_ReferenceDocClass where code ='08' and ts in
(select top 1 ts from GL_ReferenceDocClass where code ='08')
end