This commit is contained in:
42
PROMS/SQL Data Tools/FindLibraryProblems.sql
Normal file
42
PROMS/SQL Data Tools/FindLibraryProblems.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
declare @LibraryProblems table
|
||||
(
|
||||
DocID int Primary Key,
|
||||
LibTitle nvarchar(255),
|
||||
WorkingDrafts int,
|
||||
RODBIDs int,
|
||||
TotalCount int
|
||||
)
|
||||
Insert into @LibraryProblems
|
||||
select DocID, LibTitle, Count(distinct VersionID) WorkingDrafts, Count(Distinct RODBID) RODBIDs, Sum(HowMany) TotalCount
|
||||
From (
|
||||
select ee.DocID, libtitle
|
||||
--, ee.ContentID
|
||||
, VI.VersionID, ParentName,FolderName, AA.ROFstID , RF.RODBID, Count(*) HowMany
|
||||
from entries ee
|
||||
Join Documents dd on dd.DocID = ee.DocID
|
||||
Join vefn_getVersionItems('') VI ON ee.ContentID = VI.ContentID
|
||||
Join vefn_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
Join Associations AA ON VI.VersionID = AA.VersionID
|
||||
Join ROFsts RF ON RF.ROFstID=AA.ROFstID
|
||||
Join RODBs RD ON RF.RODbID=RD.ROdBID
|
||||
--where ee.DocID in (826,1054,2356)
|
||||
group by ee.DocID, libtitle, VI.VersionID, ParentName,FolderName, AA.ROFstID , RF.RODBID
|
||||
) T1
|
||||
Group by DocID,LibTitle
|
||||
Having Count(Distinct RODBID)>1
|
||||
|
||||
Select * from @LibraryProblems
|
||||
|
||||
select ee.DocID, libtitle
|
||||
--, ee.ContentID
|
||||
, VI.VersionID, ParentName,FolderName, AA.ROFstID , RF.RODBID, Count(*) HowMany
|
||||
from entries ee
|
||||
Join Documents dd on dd.DocID = ee.DocID
|
||||
Join vefn_getVersionItems('') VI ON ee.ContentID = VI.ContentID
|
||||
Join vefn_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
Join Associations AA ON VI.VersionID = AA.VersionID
|
||||
Join ROFsts RF ON RF.ROFstID=AA.ROFstID
|
||||
Join RODBs RD ON RF.RODbID=RD.ROdBID
|
||||
where ee.DocID in (select DocID from @LibraryProblems)
|
||||
group by ee.DocID, libtitle, VI.VersionID, ParentName,FolderName, AA.ROFstID , RF.RODBID
|
||||
|
Reference in New Issue
Block a user