Tags:
問題現(xiàn)象】
聯(lián)查銷貨單提示8156數(shù)據(jù)庫錯誤,請重試
【解決方案】
---執(zhí)行前先備份賬套,執(zhí)行后重啟服務(wù)
---刪除重復(fù)的用戶欄目方案
DELETE FROM Eap_ColumnSet_User
WHERE id IN (SELECT r.eid
FROM (SELECT Row_number()
OVER(
PARTITION BY eSolutionID, eUserId, eField, eIdSearchPlan
ORDER BY eSolutionID, eUserId, eField, eIdSearchPlan) AS rankid,
*
FROM (SELECT e.SolutionID AS eSolutionID,
e.UserId AS eUserId,
e.Field AS efield,
e.IdSearchPlan AS eIdSearchPlan,
id AS eid
FROM Eap_ColumnSet_User e
INNER JOIN (SELECT *
FROM (SELECT SolutionID,
UserId,
Field,
IdSearchPlan,
Count(*) AS y
FROM Eap_ColumnSet_User
GROUP BY SolutionID,
UserId,
Field,
IdSearchPlan)a
WHERE a.y > 1)b
ON b.SolutionID = e.SolutionID
AND b.UserId = e.UserId
AND b.Field = e.Field
AND b.IdSearchPlan = e.IdSearchPlan)h)r
WHERE r.rankid > 1)
---刪除重復(fù)欄目方案
DELETE FROM eap_ColumnSetSolution_User
WHERE id IN (SELECT r.eid
FROM (SELECT Row_number()
OVER(
PARTITION BY eSolutionID, eUserId, eIdSearchPlan
ORDER BY eSolutionID, eUserId, eIdSearchPlan) AS rankid,
*
FROM (SELECT e.SolutionID AS eSolutionID,
e.UserId AS eUserId,
e.IdSearchPlan AS eIdSearchPlan,
id AS eid
FROM eap_ColumnSetSolution_User e
INNER JOIN (SELECT *
FROM (SELECT SolutionID,
UserId,
IdSearchPlan,
Count(*) AS y
FROM eap_ColumnSetSolution_User
GROUP BY SolutionID,
UserId,
IdSearchPlan)a
WHERE a.y > 1)b
ON b.SolutionID = e.SolutionID
AND b.UserId = e.UserId
AND b.IdSearchPlan = e.IdSearchPlan)h)r
WHERE r.rankid > 1)