'what is occurring in the SQL statement below and why it may be needed
WITH CTEDOC AS
(
SELECT
ROW_NUMBER() OVER (PARTITION BY d.CaseDocumentID ORDER BY PageSequence) [rowN],
d.DocumentID
FROM tblCaseDocument cd WITH(NOLOCK)
JOIN tblDocument d WITH(NOLOCK) ON d.CaseDocumentID = cd.CaseDocumentID
WHERE NOT EXISTS
(
SELECT * FROM tblDocument (NOLOCK)
WHERE PageSequence = 1
and SourceTableID = cd.CaseDocumentID
)
AND cd.DocumentCount > 0
)
UPDATE d SET PageSequence = cte.rowN
FROM CTEDOC CTE
JOIN tblDocument d (NOLOCK) ON d.DocumentID = cte.DocumentID
uodate Occured for both files?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
