厦门用友软件 畅捷通T+某一个操作员打开基础档案(存货、物料清单等)提示8156数据库错误
---该脚本为通用脚本,以后遇到此类问题也可以处理,之前有缺陷,已经修复,历史数据待处理。
---执行前先备份账套,执行后重启服务
---删除重复的用户栏目方案
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)
---删除重复栏目方案
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)