This commit is contained in:
parent
dc9eca0953
commit
3dd59e20d8
@ -0,0 +1,12 @@
|
||||
declare @CommandLine nvarchar(max)
|
||||
SET @CommandLine = 'select distinct ru.contentid, "{Name}" dbname,
|
||||
case when cast(data as nvarchar(max)) like "%mergedranges%" then "true" else "false" end merged from ~Grids GG
|
||||
Join ~ROUsages RU ON RU.ContentID =GG.ContentID
|
||||
where cast(data as nvarchar(max)) like "%:" + cast(rousageid as varchar(10)) + "%:" + cast(rousageid as varchar(10)) + "%"
|
||||
'
|
||||
declare @CommandLines nvarchar(max)
|
||||
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + Replace(Replace(Replace(@CommandLine,'~','{Name}.dbo.'),'{Name}',Name),'"','''')
|
||||
from Sys.Databases where name like 'VEPROMS%'
|
||||
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t1 '--where HowMany > 0'
|
||||
print @CommandLines
|
||||
EXEC SP_EXECUTESQL @CommandLines
|
4
PROMS/SQL Data Tools/AnnotationsTypeYearCount.sql
Normal file
4
PROMS/SQL Data Tools/AnnotationsTypeYearCount.sql
Normal file
@ -0,0 +1,4 @@
|
||||
select att.name, year(atn.dts) atnYear, count(*) howmany --, min(atn.dts) mindts, max(atn.DTS) maxdts
|
||||
from AnnotationTypes att
|
||||
join Annotations atn on atn.TypeID = att.TypeID
|
||||
group by att.Name, year(atn.DTS)
|
@ -0,0 +1 @@
|
||||
Update contents set type=goodnumber where type=badnumber
|
10
PROMS/SQL Data Tools/Barakah/Unit Info tokens in EOPs.sql
Normal file
10
PROMS/SQL Data Tools/Barakah/Unit Info tokens in EOPs.sql
Normal file
@ -0,0 +1,10 @@
|
||||
--Select * from ROUsages where ROID like 'FF%'
|
||||
|
||||
Select VI.VersionID, cc.ContentID,dbo.ve_GetShortPath(Itemid) Location, VN.FolderName, cc.Text
|
||||
from Contents cc
|
||||
JOIN VEFN_GetVersionItems('209,206,207') VI ON VI.ContentID = CC.ContentID
|
||||
--JOIN VEFN_GetVersionItems('206') VI ON VI.ContentID = CC.ContentID
|
||||
JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
--left JOIN (Select * from vefn_ProcedureByProcID('742188')) VP ON VP.ContentID = CC.ContentID
|
||||
where cc.Text like '%000C%' OR cc.Text like '%FFFF%'
|
||||
|
38
PROMS/SQL Data Tools/Bold no more/Bold no more.sql
Normal file
38
PROMS/SQL Data Tools/Bold no more/Bold no more.sql
Normal file
@ -0,0 +1,38 @@
|
||||
select * from vefn_getversionnames ()
|
||||
|
||||
--find occurences
|
||||
select itemid, text from contents cc
|
||||
join vefn_getversionitems ('163') vi on cc.contentid = vi.contentid
|
||||
where text like '%will TRIP%'
|
||||
and text like '%will TRIP%'
|
||||
COLLATE Latin1_General_CS_AS
|
||||
|
||||
--remove bold and underline
|
||||
update cc set text = replace(text, 'CONCENTRATION OPEN', 'CONCENTRATION\u160?OPEN') from contents cc
|
||||
join vefn_getversionitems ('163') vi on cc.contentid = vi.contentid
|
||||
where text like '%CONCENTRATION OPEN%'
|
||||
COLLATE Latin1_General_CS_AS
|
||||
|
||||
--add bold and underline
|
||||
update cc set text = replace(text, 'are NOT in', 'are \b\ul NOT\b0\ulnone in') from contents cc
|
||||
join vefn_getversionitems ('162') vi on cc.contentid = vi.contentid
|
||||
where text like '%are NOT in%'
|
||||
COLLATE Latin1_General_CS_AS
|
||||
|
||||
--add bolding
|
||||
update cc set text = replace(text, 'display AND SEND', 'display AND \b SEND\b0\none ') from contents cc
|
||||
join vefn_getversionitems ('161') vi on cc.contentid = vi.contentid
|
||||
where text like '%display AND SEND%'
|
||||
COLLATE Latin1_General_CS_AS
|
||||
|
||||
--add underlining
|
||||
update cc set text = replace(text, 'Either "Ch', 'If \ul either\ulnone CC') from contents cc
|
||||
join vefn_getversionitems ('159') vi on cc.contentid = vi.contentid
|
||||
where text like '%If either CC%'
|
||||
COLLATE Latin1_General_CS_AS
|
||||
|
||||
--(change text)
|
||||
update cc set text = 'ATTACHMENT 1 - INPUT MODULE FAILURE' from contents cc
|
||||
join vefn_getversionitems ('161') vi on cc.contentid = vi.contentid
|
||||
where text like 'ATTACHMENT 1 - INPUT MODULE FAILURE'
|
||||
COLLATE Latin1_General_CS_AS
|
24
PROMS/SQL Data Tools/Bold no more/README.txt
Normal file
24
PROMS/SQL Data Tools/Bold no more/README.txt
Normal file
@ -0,0 +1,24 @@
|
||||
Select line 1 and run against Barakah_ARPs to get folder numbers [EF-0001 (159) RW-0001 (163)]
|
||||
Lines 8, 14, 20, 26, 32, 38 make the search/Fix case sensitive
|
||||
|
||||
Lines 4-8 selected:
|
||||
(‘###’) Folder Number
|
||||
‘% %’ text wanting to change *same text both places*
|
||||
Lines 11-14 selected:
|
||||
11 ‘ ‘, ‘ \u160? ‘ first ‘ ‘ is the Text to be changed second ‘ \u160? ‘ (the \u160? Is the hard space being added and it can go before or after the word being unbolded)
|
||||
12 (‘###’) Folder number
|
||||
13 ‘% %’ Same text as ‘ ‘ on line 11
|
||||
Lines 17-20 selected:
|
||||
17 ‘ ‘, ‘ \b\ul \b0\ulnone ‘ first ‘ ‘ is the Text to be changed second ‘ \b\ul \b0\ulnone ‘ (\b\ul \b0\ulnone turns on then turns off bolding and underlining) there are 2 spaces between \b0\ulnone & the ‘ or next word
|
||||
18 (‘###’) Folder number
|
||||
19 ‘% %’ Same text as ‘ ‘ on line 17
|
||||
Lines 23-26 selected:
|
||||
23 ‘ ‘, ‘ \b \b0\lnone ‘ first ‘ ‘ is the Text to be changed second ‘ \b \b0\none ‘ (\b \b0\none turns on then turns off bolding) there are 2 spaces between \b0\none & the ‘ or next word
|
||||
24 (‘###’) Folder number
|
||||
25 ‘% %’ Same text as ‘ ‘ on line 23
|
||||
Lines 29-32 selected:
|
||||
29 ‘ ‘, ‘ \ul \ulnone ‘ first ‘ ‘ is the Text to be changed second ‘ \ul \ulnone ‘ (\ul \ulnone turns on then turns off underlining) there are 2 spaces between \ulnone & the ‘ or next word
|
||||
30 (‘###’) Folder number
|
||||
31 ‘% %’ Same text as ‘ ‘ on line 29
|
||||
|
||||
|
3
PROMS/SQL Data Tools/Case sensitive text compare.sql
Normal file
3
PROMS/SQL Data Tools/Case sensitive text compare.sql
Normal file
@ -0,0 +1,3 @@
|
||||
select ccb4.Text oldtext,cc.text newtext from Contents ccb4
|
||||
join veproms_mns.dbo.Contents cc on ccb4.ContentID=cc.ContentID
|
||||
where cc.Text != ccb4.text Collate sql_latin1_General_CP1_CS_AS
|
@ -0,0 +1,500 @@
|
||||
|
||||
|
||||
|
||||
Set NoCount On;
|
||||
|
||||
Declare @ShowDetails Bit;
|
||||
Declare @IsAutoFixEnabled Bit;
|
||||
|
||||
|
||||
/*================================================================================================================================*/
|
||||
|
||||
Set @ShowDetails = 1;
|
||||
Set @IsAutoFixEnabled = 0;
|
||||
|
||||
/*================================================================================================================================*/
|
||||
|
||||
|
||||
-- Local Variables
|
||||
Declare @IssueNum Int;
|
||||
Declare @Description VarChar(Max);
|
||||
Declare @SqlTables VarChar(250);
|
||||
Declare @FixType VarChar(50); -- Auto or Manual
|
||||
Declare @NumOfRecords Int;
|
||||
|
||||
-- Create Results Table
|
||||
Declare @Results as Table (IssueNum Int Primary Key, SqlTables VarChar(250), [Description] VarChar(Max), FixType VarChar(50), NumOfRecords Int);
|
||||
|
||||
-- Default / Initialize Variables
|
||||
Set @IssueNum = 0;
|
||||
Set @Description = 'n/a';
|
||||
Set @SqlTables = 'n/a';
|
||||
Set @FixType = 'Manual';
|
||||
Set @NumOfRecords = 0;
|
||||
|
||||
|
||||
|
||||
/*======================================================================================================*/
|
||||
-- Case/Issue #1: [Contents Table] - Records with space before Links after parenthesis
|
||||
/*======================================================================================================*/
|
||||
Set @IssueNum = 1;
|
||||
Set @Description = 'Records with space before Links after parenthesis';
|
||||
Set @SqlTables = 'Contents';
|
||||
Set @FixType = 'Auto';
|
||||
|
||||
|
||||
-- Get Record Count for the Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Select @NumOfRecords = Count(1)
|
||||
From Contents c with (NoLock) Where c.[Text] like '%( \v%';
|
||||
|
||||
-- If Any Bad Data Records Exist, Get Record Details for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@ShowDetails = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Select Concat('Case/Issue #', @IssueNum, ': [', @SqlTables, '] - ', @Description, ' (', @NumOfRecords, ' record(s))');
|
||||
|
||||
Select c.ContentID, c.[Text], c.Config, c.DTS, c.UserID, c.LastChanged From Contents c with (NoLock) Where c.[Text] like '%( \v%';
|
||||
End
|
||||
|
||||
-- If Enabled and Any Bad Data Records Exist, Automatically fix the bad data records for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@IsAutoFixEnabled = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Update tblContents Set [Text] = Right([Text], Len([Text])-1) Where [Text] like '%( \v%';
|
||||
End
|
||||
|
||||
|
||||
-- Create Results Record for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Insert Into @Results (IssueNum, SqlTables, [Description], FixType, NumOfRecords)
|
||||
Values (@IssueNum, @SqlTables, @Description, @FixType, @NumOfRecords);
|
||||
|
||||
|
||||
|
||||
|
||||
/*======================================================================================================*/
|
||||
-- Case/Issue #2: [Contents Table] - Records with space before Links as starting text
|
||||
/*======================================================================================================*/
|
||||
Set @IssueNum = 2;
|
||||
Set @Description = 'Records with space before Links as starting text';
|
||||
Set @SqlTables = 'Contents';
|
||||
Set @FixType = 'Auto';
|
||||
|
||||
|
||||
-- Get Record Count for the Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Select @NumOfRecords = Count(1)
|
||||
From Contents c with (NoLock) Where c.[Text] like ' \v%';
|
||||
|
||||
-- If Any Bad Data Records Exist, Get Record Details for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@ShowDetails = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Select Concat('Case/Issue #', @IssueNum, ': [', @SqlTables, '] - ', @Description, ' (', @NumOfRecords, ' record(s))');
|
||||
|
||||
Select c.ContentID, c.[Text], c.Config, c.DTS, c.UserID, c.LastChanged From Contents c with (NoLock) Where c.[Text] like ' \v%';
|
||||
End
|
||||
|
||||
-- If Enabled and Any Bad Data Records Exist, Automatically fix the bad data records for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@IsAutoFixEnabled = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Update tblContents Set [Text] = Right([Text], Len([Text])-1) Where [Text] like ' \v%';
|
||||
End
|
||||
|
||||
|
||||
-- Create Results Record for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Insert Into @Results (IssueNum, SqlTables, [Description], FixType, NumOfRecords)
|
||||
Values (@IssueNum, @SqlTables, @Description, @FixType, @NumOfRecords);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*======================================================================================================*/
|
||||
-- Case/Issue #3: [Contents Table] - Records with extra spaces before RO Links
|
||||
/*======================================================================================================*/
|
||||
Set @IssueNum = 3;
|
||||
Set @Description = 'Records with extra spaces before RO Links';
|
||||
Set @SqlTables = 'Contents';
|
||||
Set @FixType = 'Auto';
|
||||
|
||||
|
||||
-- Get Record Count for the Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
--Select @NumOfRecords = Count(1)
|
||||
--From Contents c with (NoLock) Where c.[Text] like '% \v%';
|
||||
|
||||
Select @NumOfRecords = Count(1)
|
||||
From Contents c with (NoLock)
|
||||
Where c.[Text] like '% \v%' And Not (c.[Text] like '%\ul \v%' Or c.[Text] like '%\ulnone \v%' Or c.[Text] like '%\up0 \v%' Or c.[Text] like '%\b0 \v%' Or c.[Text] like '%\i0 \v%');
|
||||
|
||||
-- If Any Bad Data Records Exist, Get Record Details for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@ShowDetails = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Select Concat('Case/Issue #', @IssueNum, ': [', @SqlTables, '] - ', @Description, ' (', @NumOfRecords, ' record(s))');
|
||||
|
||||
--Select c.ContentID, c.[Text], c.Config, c.DTS, c.UserID, c.LastChanged From Contents c with (NoLock) Where c.[Text] like '% \v%';
|
||||
|
||||
Select c.ContentID, c.[Text], c.Config, c.DTS, c.UserID, c.LastChanged From Contents c with (NoLock)
|
||||
Where c.[Text] like '% \v%' And Not (c.[Text] like '%\ul \v%' Or c.[Text] like '%\ulnone \v%' Or c.[Text] like '%\up0 \v%' Or c.[Text] like '%\b0 \v%' Or c.[Text] like '%\i0 \v%');
|
||||
End
|
||||
|
||||
-- If Enabled and Any Bad Data Records Exist, Automatically fix the bad data records for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@IsAutoFixEnabled = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
--Update tblContents Set [Text] = Replace([Text], ' \v', ' \v') Where [Text] like '% \v%';
|
||||
|
||||
Update tblContents Set [Text] = Replace([Text], ' \v', ' \v')
|
||||
Where [Text] like '% \v%' And Not ([Text] like '%\ul \v%' Or [Text] like '%\ulnone \v%' Or [Text] like '%\up0 \v%' Or [Text] like '%\b0 \v%' Or [Text] like '%\i0 \v%');
|
||||
End
|
||||
|
||||
|
||||
-- Create Results Record for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Insert Into @Results (IssueNum, SqlTables, [Description], FixType, NumOfRecords)
|
||||
Values (@IssueNum, @SqlTables, @Description, @FixType, @NumOfRecords);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*======================================================================================================*/
|
||||
-- Case/Issue #4: [Grids Table] - Records with extra spaces before RO Links
|
||||
/*======================================================================================================*/
|
||||
Set @IssueNum = 4;
|
||||
Set @Description = 'Records with extra spaces before RO Links';
|
||||
Set @SqlTables = 'Grids';
|
||||
Set @FixType = 'Auto';
|
||||
|
||||
|
||||
-- Get Record Count for the Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Select @NumOfRecords = Count(1)
|
||||
From Grids g with (NoLock)
|
||||
Where Cast(g.[Data] as VarChar(Max)) like '% \v%'
|
||||
And Not (Cast(g.[Data] as VarChar(Max)) like '%\ul \v%' Or Cast(g.[Data] as VarChar(Max)) like '%\ulnone \v%'
|
||||
Or Cast(g.[Data] as VarChar(Max)) like '%\up0 \v%' Or Cast(g.[Data] as VarChar(Max)) like '%\b0 \v%' Or Cast(g.[Data] as VarChar(Max)) like '%\i0 \v%');
|
||||
|
||||
-- If Any Bad Data Records Exist, Get Record Details for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@ShowDetails = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Select Concat('Case/Issue #', @IssueNum, ': [', @SqlTables, '] - ', @Description, ' (', @NumOfRecords, ' record(s))');
|
||||
|
||||
Select g.ContentID, g.Config, g.DTS, g.UserID, g.LastChanged, Cast(g.[Data] as VarChar(Max)) as 'XmlDataAsText', g.[Data] as 'XmlData'
|
||||
From Grids g with (NoLock)
|
||||
Where Cast(g.[Data] as VarChar(Max)) like '% \v%'
|
||||
And Not (Cast(g.[Data] as VarChar(Max)) like '%\ul \v%' Or Cast(g.[Data] as VarChar(Max)) like '%\ulnone \v%'
|
||||
Or Cast(g.[Data] as VarChar(Max)) like '%\up0 \v%' Or Cast(g.[Data] as VarChar(Max)) like '%\b0 \v%' Or Cast(g.[Data] as VarChar(Max)) like '%\i0 \v%');
|
||||
End
|
||||
|
||||
-- If Enabled and Any Bad Data Records Exist, Automatically fix the bad data records for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@IsAutoFixEnabled = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
|
||||
Update tblGrids Set [Data] = Cast(Replace(Cast([Data] as VarChar(Max)), ' \v', ' \v') as xml)
|
||||
Where Cast([Data] as VarChar(Max)) like '% \v%'
|
||||
And Not (Cast([Data] as VarChar(Max)) like '%\ul \v%' Or Cast([Data] as VarChar(Max)) like '%\ulnone \v%'
|
||||
Or Cast([Data] as VarChar(Max)) like '%\up0 \v%' Or Cast([Data] as VarChar(Max)) like '%\b0 \v%' Or Cast([Data] as VarChar(Max)) like '%\i0 \v%');
|
||||
End
|
||||
|
||||
|
||||
-- Create Results Record for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Insert Into @Results (IssueNum, SqlTables, [Description], FixType, NumOfRecords)
|
||||
Values (@IssueNum, @SqlTables, @Description, @FixType, @NumOfRecords);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*======================================================================================================*/
|
||||
-- Case/Issue #5: [Contents Table] - Records with UnEscaped Hyphens
|
||||
/*======================================================================================================*/
|
||||
Set @IssueNum = 5;
|
||||
Set @Description = 'Records with UnEscaped Hyphens';
|
||||
Set @SqlTables = 'Contents';
|
||||
Set @FixType = 'Auto';
|
||||
|
||||
|
||||
-- Get Record Count for the Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Select @NumOfRecords = Count(1)
|
||||
From Contents c with (NoLock) Where c.[Text] like '%-%';
|
||||
|
||||
-- If Any Bad Data Records Exist, Get Record Details for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@ShowDetails = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Select Concat('Case/Issue #', @IssueNum, ': [', @SqlTables, '] - ', @Description, ' (', @NumOfRecords, ' record(s))');
|
||||
|
||||
Select c.ContentID, c.[Text], c.Config, c.DTS, c.UserID, c.LastChanged From Contents c with (NoLock) Where c.[Text] like '%-%';
|
||||
End
|
||||
|
||||
-- If Enabled and Any Bad Data Records Exist, Automatically fix the bad data records for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@IsAutoFixEnabled = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Update tblContents Set [Text] = Replace([Text], '-', '\u8209?') Where [Text] like '%-%';
|
||||
End
|
||||
|
||||
|
||||
-- Create Results Record for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Insert Into @Results (IssueNum, SqlTables, [Description], FixType, NumOfRecords)
|
||||
Values (@IssueNum, @SqlTables, @Description, @FixType, @NumOfRecords);
|
||||
|
||||
|
||||
|
||||
|
||||
/*======================================================================================================*/
|
||||
-- Case/Issue #6: [Grid Table] - Records with Escaped Hyphens
|
||||
/*======================================================================================================*/
|
||||
Set @IssueNum = 6;
|
||||
Set @Description = 'Records with Escaped Hyphens';
|
||||
Set @SqlTables = 'Grids';
|
||||
Set @FixType = 'Auto';
|
||||
|
||||
|
||||
-- Get Record Count for the Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Select @NumOfRecords = Count(1)
|
||||
From Grids g with (NoLock) Where Cast(g.[Data] as VarChar(Max)) like '%\u8209?%';
|
||||
|
||||
-- If Any Bad Data Records Exist, Get Record Details for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@ShowDetails = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Select Concat('Case/Issue #', @IssueNum, ': [', @SqlTables, '] - ', @Description, ' (', @NumOfRecords, ' record(s))');
|
||||
|
||||
Select g.ContentID, g.Config, g.DTS, g.UserID, g.LastChanged, Cast(g.[Data] as VarChar(Max)) as 'XmlDataAsText', g.[Data] as 'XmlData'
|
||||
From Grids g with (NoLock) Where Cast(g.[Data] as VarChar(Max)) like '%\u8209?%';
|
||||
End
|
||||
|
||||
-- If Enabled and Any Bad Data Records Exist, Automatically fix the bad data records for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@IsAutoFixEnabled = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Update tblGrids Set [Data] = Cast(Replace(Cast([Data] as VarChar(Max)), '\u8209?', '-') as xml) Where Cast([Data] as VarChar(Max)) like '%\u8209?%';
|
||||
End
|
||||
|
||||
|
||||
-- Create Results Record for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Insert Into @Results (IssueNum, SqlTables, [Description], FixType, NumOfRecords)
|
||||
Values (@IssueNum, @SqlTables, @Description, @FixType, @NumOfRecords);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*======================================================================================================*/
|
||||
-- Case/Issue #7: [Contents Table] - Records with Double <START] tags
|
||||
/*======================================================================================================*/
|
||||
Set @IssueNum = 7;
|
||||
Set @Description = 'Records with Double <START] tags';
|
||||
Set @SqlTables = 'Contents';
|
||||
Set @FixType = 'Auto';
|
||||
|
||||
|
||||
-- Get Record Count for the Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Select @NumOfRecords = Count(1)
|
||||
From Contents c with (NoLock) left outer join Grids g with (NoLock) on g.ContentID = c.ContentID Where g.ContentID is null And c.[Text] like '%<START]<START]%';
|
||||
|
||||
-- If Any Bad Data Records Exist, Get Record Details for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@ShowDetails = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Select Concat('Case/Issue #', @IssueNum, ': [', @SqlTables, '] - ', @Description, ' (', @NumOfRecords, ' record(s))');
|
||||
|
||||
Select c.ContentID, c.[Text], c.Config, c.DTS, c.UserID, c.LastChanged
|
||||
From Contents c with (NoLock) left outer join Grids g with (NoLock) on g.ContentID = c.ContentID
|
||||
Where g.ContentID is null And c.[Text] like '%<START]<START]%';
|
||||
End
|
||||
|
||||
-- If Enabled and Any Bad Data Records Exist, Automatically fix the bad data records for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@IsAutoFixEnabled = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Update tblContents Set [Text] = Replace([Text], '<START]<START]', '<START]') Where [Text] like '%<START]<START]%' And ContentID Not in (Select ContentID From Grids);
|
||||
End
|
||||
|
||||
|
||||
-- Create Results Record for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Insert Into @Results (IssueNum, SqlTables, [Description], FixType, NumOfRecords)
|
||||
Values (@IssueNum, @SqlTables, @Description, @FixType, @NumOfRecords);
|
||||
|
||||
|
||||
|
||||
|
||||
/*======================================================================================================*/
|
||||
-- Case/Issue #8: [Grids/Contents Table] - Records with Double <START] tags
|
||||
/*======================================================================================================*/
|
||||
Set @IssueNum = 8;
|
||||
Set @Description = 'Records with Double <START] tags';
|
||||
Set @SqlTables = 'Grids/Contents';
|
||||
Set @FixType = 'Auto';
|
||||
|
||||
|
||||
-- Get Record Count for the Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Select @NumOfRecords = Count(1)
|
||||
From Contents c with (NoLock) inner join Grids g with (NoLock) on g.ContentID = c.ContentID
|
||||
Where (c.[Text] like '%<START]<START]%' Or Cast(g.[Data] as VarChar(Max)) like '%<START]<START]%');
|
||||
|
||||
--Select c.ContentID, c.[Text] as 'Text', Cast(g.[Data] as VarChar(Max)) as 'XmlDataAsText', g.[Data] as 'XmlData'
|
||||
--From Contents c with (NoLock) inner join Grids g with (NoLock) on g.ContentID = c.ContentID
|
||||
--Where (c.[Text] like '%<START]<START]%' Or Cast(g.[Data] as VarChar(Max)) like '%<START]<START]%');
|
||||
|
||||
-- If Any Bad Data Records Exist, Get Record Details for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@ShowDetails = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Select Concat('Case/Issue #', @IssueNum, ': [', @SqlTables, '] - ', @Description, ' (', @NumOfRecords, ' record(s))');
|
||||
|
||||
Select c.ContentID, c.[Text], Cast(g.[Data] as VarChar(Max)) as 'XmlDataAsText', g.[Data] as 'XmlData'
|
||||
From Contents c with (NoLock) inner join Grids g with (NoLock) on g.ContentID = c.ContentID
|
||||
Where (c.[Text] like '%<START]<START]%' Or Cast(g.[Data] as VarChar(Max)) like '%<START]<START]%');
|
||||
End
|
||||
|
||||
-- If Enabled and Any Bad Data Records Exist, Automatically fix the bad data records for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@IsAutoFixEnabled = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Update tblContents Set [Text] = Replace([Text], '<START]<START]', '<START]') Where [Text] like '%<START]<START]%';
|
||||
Update tblGrids Set [Data] = Cast(Replace(Cast([Data] as VarChar(Max)), '<START]<START]', '<START]') as xml) Where Cast([Data] as VarChar(Max)) like '%<START]<START]%';
|
||||
End
|
||||
|
||||
|
||||
-- Create Results Record for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Insert Into @Results (IssueNum, SqlTables, [Description], FixType, NumOfRecords)
|
||||
Values (@IssueNum, @SqlTables, @Description, @FixType, @NumOfRecords);
|
||||
|
||||
|
||||
|
||||
|
||||
/*======================================================================================================*/
|
||||
-- Case/Issue #9: [Contents Table] - Records with Num of <START] / [END> tags don't match
|
||||
/*======================================================================================================*/
|
||||
Set @IssueNum = 9;
|
||||
Set @Description = 'Num of <START] / [END> tags don''t match';
|
||||
Set @SqlTables = 'Contents';
|
||||
Set @FixType = 'Manual';
|
||||
|
||||
|
||||
-- Get Record Count for the Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
With zContents as
|
||||
(
|
||||
Select c.ContentID, c.[Text], dbo.vefn_NumOfOccurrences(c.[Text], '<START]') as 'StartCntText', dbo.vefn_NumOfOccurrences(c.[Text], '[END>') as 'EndCntText'
|
||||
From Contents c with (NoLock) left outer join Grids g with (NoLock) on g.ContentID = c.ContentID Where g.ContentID is null
|
||||
)
|
||||
Select @NumOfRecords = Count(1)
|
||||
From zContents z Where z.StartCntText <> z.EndCntText;
|
||||
|
||||
-- If Any Bad Data Records Exist, Get Record Details for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@ShowDetails = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Select Concat('Case/Issue #', @IssueNum, ': [', @SqlTables, '] - ', @Description, ' (', @NumOfRecords, ' record(s))');
|
||||
|
||||
With zContents as
|
||||
(
|
||||
Select c.ContentID, c.[Text], dbo.vefn_NumOfOccurrences(c.[Text], '<START]') as 'StartCntText', dbo.vefn_NumOfOccurrences(c.[Text], '[END>') as 'EndCntText'
|
||||
From Contents c with (NoLock) left outer join Grids g with (NoLock) on g.ContentID = c.ContentID Where g.ContentID is null
|
||||
)
|
||||
Select z.*
|
||||
From zContents z Where z.StartCntText <> z.EndCntText;
|
||||
End
|
||||
|
||||
-- If Enabled and Any Bad Data Records Exist, Automatically fix the bad data records for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
-- Data needs to be reviewed / fixed Manually
|
||||
|
||||
|
||||
-- Create Results Record for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Insert Into @Results (IssueNum, SqlTables, [Description], FixType, NumOfRecords)
|
||||
Values (@IssueNum, @SqlTables, @Description, @FixType, @NumOfRecords);
|
||||
|
||||
|
||||
|
||||
|
||||
/*======================================================================================================*/
|
||||
-- Case/Issue #10: [Grids/Contents Table] - Records with Num of <START] / [END> tags don't match
|
||||
/*======================================================================================================*/
|
||||
Set @IssueNum = 10;
|
||||
Set @Description = 'Num of <START] / [END> tags don''t match';
|
||||
Set @SqlTables = 'Grids/Contents';
|
||||
Set @FixType = 'Manual';
|
||||
|
||||
|
||||
-- Get Record Count for the Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
With zContents as
|
||||
(
|
||||
Select c.ContentID,
|
||||
dbo.vefn_NumOfOccurrences(c.[Text], '<START]') as 'StartCntText', dbo.vefn_NumOfOccurrences(c.[Text], '[END>') as 'EndCntText',
|
||||
dbo.vefn_NumOfOccurrences(Replace(Cast(g.[Data] as VarChar(Max)),'<', '<'), '<START]') as 'StartCntXml',
|
||||
dbo.vefn_NumOfOccurrences(Replace(Cast(g.[Data] as VarChar(Max)),'>', '>'), '[END>') as 'EndCntXml',
|
||||
c.[Text], Cast(g.[Data] as VarChar(Max)) as 'XmlDataAsText', g.[Data] as 'XmlData'
|
||||
From Contents c with (NoLock) inner join Grids g with (NoLock) on g.ContentID = c.ContentID
|
||||
)
|
||||
Select @NumOfRecords = Count(1)
|
||||
From zContents z Where (z.StartCntText <> z.EndCntText Or z.StartCntXml <> z.EndCntXml);
|
||||
|
||||
-- If Any Bad Data Records Exist, Get Record Details for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
If (@ShowDetails = 1 And @NumOfRecords > 0)
|
||||
Begin
|
||||
Select Concat('Case/Issue #', @IssueNum, ': [', @SqlTables, '] - ', @Description, ' (', @NumOfRecords, ' record(s))');
|
||||
|
||||
With zContents as
|
||||
(
|
||||
Select c.ContentID,
|
||||
dbo.vefn_NumOfOccurrences(c.[Text], '<START]') as 'StartCntText', dbo.vefn_NumOfOccurrences(c.[Text], '[END>') as 'EndCntText',
|
||||
dbo.vefn_NumOfOccurrences(Replace(Cast(g.[Data] as VarChar(Max)),'<', '<'), '<START]') as 'StartCntXml',
|
||||
dbo.vefn_NumOfOccurrences(Replace(Cast(g.[Data] as VarChar(Max)),'>', '>'), '[END>') as 'EndCntXml',
|
||||
c.[Text], Cast(g.[Data] as VarChar(Max)) as 'XmlDataAsText', g.[Data] as 'XmlData'
|
||||
From Contents c with (NoLock) inner join Grids g with (NoLock) on g.ContentID = c.ContentID
|
||||
)
|
||||
Select z.*
|
||||
From zContents z Where (z.StartCntText <> z.EndCntText Or z.StartCntXml <> z.EndCntXml);
|
||||
End
|
||||
|
||||
-- If Enabled and Any Bad Data Records Exist, Automatically fix the bad data records for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
-- Data needs to be reviewed / fixed Manually
|
||||
|
||||
|
||||
-- Create Results Record for the specific Case/Issue
|
||||
---------------------------------------------------------------------------------------
|
||||
Insert Into @Results (IssueNum, SqlTables, [Description], FixType, NumOfRecords)
|
||||
Values (@IssueNum, @SqlTables, @Description, @FixType, @NumOfRecords);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*================================================================================================================================*/
|
||||
-- Return analysis/results for all of the bad data Case/Issue(s)
|
||||
/*================================================================================================================================*/
|
||||
Select IssueNum as 'Case #', SqlTables as 'SQL Tables', [Description] as 'Description', FixType as 'Type of Fix', NumOfRecords as '# of Records'
|
||||
From @Results Order By IssueNum Asc;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
12
PROMS/SQL Data Tools/CheckAndFixConfigXMLforPSI.sql
Normal file
12
PROMS/SQL Data Tools/CheckAndFixConfigXMLforPSI.sql
Normal file
@ -0,0 +1,12 @@
|
||||
--select contentid,config,cast(config as xml) xConfig from contents
|
||||
|
||||
-- Check to see if there are any XML conversion issues.
|
||||
-- select max(cast(cast(config as xml) as varchar(max))) test from Contents
|
||||
|
||||
-- Check for erronious PSI Data
|
||||
select * from Contents where Config like '%<PSI %'
|
||||
|
||||
--Remove PSI Node
|
||||
--Update Contents Set Config = substring(config,1,charindex('<PSI ',config))+'/Config>' from Contents where Config like '%<PSI %'
|
||||
|
||||
--NOTE: First run the entire query, then run just the last line above, then run the entire query again to verify there are none left
|
9
PROMS/SQL Data Tools/CheckForMissingImages.sql
Normal file
9
PROMS/SQL Data Tools/CheckForMissingImages.sql
Normal file
@ -0,0 +1,9 @@
|
||||
--Get count of Figures avaailable for each Procedure set
|
||||
select FolderName, AA.ROFSTID, Count(FF.ROFSTID) HowMany from associations AA
|
||||
JOIN VEFN_GetVersionNames() VN ON AA.VersionID = VN.VersionID
|
||||
Join ROFSTs RF ON RF.ROFSTID = AA.ROFSTID
|
||||
left Join Figures FF on FF.ROFSTID = AA.ROFSTID
|
||||
group by foldername, AA.ROFSTID
|
||||
|
||||
--Get count of figures associated with each ROFST
|
||||
Select RF.ROFSTID, RF.DTS,COunt(FF.ROFSTID) HowMany From ROFSTs RF Left Join Figures FF ON FF.ROfstID = RF.ROFSTID Group BY RF.ROFSTID, RF.DTS
|
10
PROMS/SQL Data Tools/CheckROs.sql
Normal file
10
PROMS/SQL Data Tools/CheckROs.sql
Normal file
@ -0,0 +1,10 @@
|
||||
select vn.versionid, FolderName, aa.rofstid, rf.rodbid, rf.dts, rd.Roname, rd.folderpath, ru.rodbid crodbid, count (*) howmany
|
||||
from vefn_getversionnames() vn
|
||||
join vefn_getversionitems('') vi on vn.versionid = vi.versionid
|
||||
join rousages ru on ru.contentid = vi.contentid
|
||||
join associations aa on aa.versionid = vn.versionid
|
||||
join rofsts rf on rf.rofstid = aa.rofstid
|
||||
join rodbs rd on rf.rodbid = rd.rodbid
|
||||
where rd.rodbid <> ru.rodbid
|
||||
group by vn.versionid, FolderName, aa.rofstid, rf.rodbid, rf.dts, rd.Roname, rd.folderpath, ru.rodbid
|
||||
order by rf.dts
|
@ -0,0 +1,26 @@
|
||||
select distinct t1.Name,t1.pageStyleName from
|
||||
(
|
||||
select * from
|
||||
(
|
||||
select ff.Name,xPageStyle.value('../@Name','varchar(100)') pageStyleName, xPageStyle.value('@Token','varchar(100)') token
|
||||
from Formats ff
|
||||
cross apply Data.nodes('//PageStyle/Item') tPageStyle(xPageStyle)
|
||||
where ff.Name like 'CWE%' or ff.Name like 'EX%'
|
||||
and xPageStyle.value('@Token','varchar(100)') not like '{BOX%'
|
||||
) ah
|
||||
) t1
|
||||
left join
|
||||
(
|
||||
select * from
|
||||
(
|
||||
select * from
|
||||
(
|
||||
select ff.Name,xPageStyle.value('../@Name','varchar(100)') pageStyleName, xPageStyle.value('@Token','varchar(100)') token
|
||||
from Formats ff
|
||||
cross apply Data.nodes('//PageStyle/Item') tPageStyle(xPageStyle)
|
||||
where ff.Name like 'CWE%' or ff.Name like 'EX%'
|
||||
) ah
|
||||
where token like '{BOX%'
|
||||
) ah
|
||||
) t2 on t1.name = t2.name and t1.pagestylename = t2.pagestylename
|
||||
where t2.name is null
|
@ -0,0 +1 @@
|
||||
select type,count(*) howmany from contents where type in(20006,20007,20020,20021,20022,20023,20026,20027,20028,20029,20032) group by type
|
72
PROMS/SQL Data Tools/CleanUpSectionsAAndSteps_CalvertOPS.sql
Normal file
72
PROMS/SQL Data Tools/CleanUpSectionsAAndSteps_CalvertOPS.sql
Normal file
@ -0,0 +1,72 @@
|
||||
|
||||
|
||||
declare @CleanUp Table
|
||||
(
|
||||
ItemID int primary key,
|
||||
ContentID int
|
||||
)
|
||||
|
||||
Insert Into @Cleanup
|
||||
select ItemID, ContentID from (
|
||||
select pp.itemid ppitemid from vefn_getVersionItems('') VI
|
||||
join vefn_getversionnames() VN ON vn.versionid =vi.versionid
|
||||
join parts pp on pp.contentID = vi.ContentID and FromType = 6
|
||||
Where vi.ContentID in(Select ContentID from Parts where FromType = 2) -- Sections
|
||||
) AH
|
||||
Cross Apply vefn_SiblingChildrenItems(ppItemID)
|
||||
|
||||
--select itemid, contentid, vn.foldername,dbo.ve_getshortpath(itemid) location from vefn_getVersionItems('') VI
|
||||
--join vefn_getversionnames() VN ON vn.versionid =vi.versionid
|
||||
--Where ContentID in(Select ContentID from Parts where FromType = 2) -- Sections
|
||||
--And ContentID in(Select ContentID from Parts where FromType = 6) -- Steps
|
||||
|
||||
|
||||
--DocVersions ItemID Should not expect to see any
|
||||
--Revisions ItemID Should not expect to see any
|
||||
--Owners OwnerItemID Should not expect to see any
|
||||
PRINT 'tblAnnotations ItemID Delete'
|
||||
delete from tblAnnotations where itemid in(select itemid from @CleanUp)
|
||||
PRINT 'AnnotationAudits ItemID Delete'
|
||||
delete from AnnotationAudits where itemid in(select itemid from @CleanUp)
|
||||
PRINT 'tblParts ItemID ContentID Delete'
|
||||
delete from tblParts where itemid in(select itemid from @CleanUp)
|
||||
PRINT 'PartAudits ItemID ContentID Delete'
|
||||
delete from PartAudits where itemid in(select itemid from @CleanUp)
|
||||
delete from zTransitions where transitionid in (select transitionid from transitions where fromid in (select contentid from @CleanUp))
|
||||
PRINT 'tblTransitions FromID Delete'
|
||||
delete from tblTransitions where fromid in(select contentid from @CleanUp)
|
||||
PRINT 'TransitionAudits FromID Delete'
|
||||
delete from TransitionAudits where fromid in(select contentid from @CleanUp)
|
||||
PRINT 'tblItems ItemID ContentID Delete (PreviousID)'
|
||||
update tblitems set previousID = null where itemid in(select itemid from @CleanUp)
|
||||
delete from tblItems where itemid in(select itemid from @CleanUp)
|
||||
PRINT 'ItemAudits ItemID ContentID Delete'
|
||||
update ItemAudits set previousID = null where itemid in(select itemid from @CleanUp)
|
||||
delete from ItemAudits where itemid in(select itemid from @CleanUp)
|
||||
PRINT 'tblEntries ContentID Delete'
|
||||
delete from tblEntries where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'EntryAudits ContentID Delete'
|
||||
delete from EntryAudits where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'tblROUsages ContentID Delete'
|
||||
delete from tblROUsages where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'ROUsageAudits ContentID Delete'
|
||||
delete from ROUsageAudits where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'tblGrids ContentID Delete'
|
||||
delete from tblGrids where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'GridAudits ContentID Delete'
|
||||
delete from GridAudits where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'tblImages ContentID Delete'
|
||||
delete from tblImages where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'ImageAudits ContentID Delete'
|
||||
delete from ImageAudits where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'Details ContentID Delete'
|
||||
delete from Details where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'ZContents ContentID Delete'
|
||||
delete from ZContents where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'tblContents ContentID Delete'
|
||||
delete from tblContents where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'ContentAudits ContentID Delete'
|
||||
delete from ContentAudits where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'Cleanup Complete'
|
||||
|
||||
|
@ -0,0 +1,77 @@
|
||||
|
||||
|
||||
declare @CleanUp Table
|
||||
(
|
||||
ItemID int primary key,
|
||||
ContentID int
|
||||
)
|
||||
|
||||
Insert Into @Cleanup
|
||||
select ItemID, ContentID from (
|
||||
select ppitemid from (
|
||||
select pp.itemid ppitemid, cast(Config as xml) xConfig from vefn_getVersionItems('') VI
|
||||
join vefn_getversionnames() VN ON vn.versionid =vi.versionid
|
||||
join contents cc ON cc.ContentID = VI.ContentID
|
||||
join parts pp on pp.contentID = vi.ContentID and FromType = 6
|
||||
Where vi.ContentID in(Select ContentID from Parts where FromType = 2)) AH
|
||||
outer apply xConfig.nodes('//SubSection') tSubSection(xSubSection)
|
||||
where IsNull(xSubSection.value('@Edit','varchar(1)'),'N') = 'N') AH
|
||||
Cross Apply vefn_SiblingChildrenItems(ppItemID)
|
||||
|
||||
--select itemid, contentid, vn.foldername,dbo.ve_getshortpath(itemid) location from vefn_getVersionItems('') VI
|
||||
--join vefn_getversionnames() VN ON vn.versionid =vi.versionid
|
||||
--Where ContentID in(Select ContentID from Parts where FromType = 2) -- Sections
|
||||
--And ContentID in(Select ContentID from Parts where FromType = 6) -- Steps
|
||||
|
||||
|
||||
--DocVersions ItemID Should not expect to see any
|
||||
--Revisions ItemID Should not expect to see any
|
||||
--Owners OwnerItemID Should not expect to see any
|
||||
PRINT 'tblAnnotations ItemID Delete'
|
||||
delete from tblAnnotations where itemid in(select itemid from @CleanUp)
|
||||
PRINT 'AnnotationAudits ItemID Delete'
|
||||
delete from AnnotationAudits where itemid in(select itemid from @CleanUp)
|
||||
PRINT 'tblParts ItemID ContentID Delete'
|
||||
delete from tblParts where itemid in(select itemid from @CleanUp)
|
||||
PRINT 'PartAudits ItemID ContentID Delete'
|
||||
delete from PartAudits where itemid in(select itemid from @CleanUp)
|
||||
delete from zTransitions where transitionid in (select transitionid from transitions where fromid in (select contentid from @CleanUp))
|
||||
PRINT 'tblTransitions FromID Delete'
|
||||
delete from tblTransitions where fromid in(select contentid from @CleanUp)
|
||||
PRINT 'TransitionAudits FromID Delete'
|
||||
delete from TransitionAudits where fromid in(select contentid from @CleanUp)
|
||||
select * from transitions where toid in(select itemid from @Cleanup)
|
||||
|
||||
PRINT 'tblItems ItemID ContentID Delete (PreviousID)'
|
||||
update tblitems set previousID = null where itemid in(select itemid from @CleanUp)
|
||||
delete from tblItems where itemid in(select itemid from @CleanUp)
|
||||
PRINT 'ItemAudits ItemID ContentID Delete'
|
||||
update ItemAudits set previousID = null where itemid in(select itemid from @CleanUp)
|
||||
delete from ItemAudits where itemid in(select itemid from @CleanUp)
|
||||
PRINT 'tblEntries ContentID Delete'
|
||||
delete from tblEntries where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'EntryAudits ContentID Delete'
|
||||
delete from EntryAudits where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'tblROUsages ContentID Delete'
|
||||
delete from tblROUsages where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'ROUsageAudits ContentID Delete'
|
||||
delete from ROUsageAudits where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'tblGrids ContentID Delete'
|
||||
delete from tblGrids where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'GridAudits ContentID Delete'
|
||||
delete from GridAudits where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'tblImages ContentID Delete'
|
||||
delete from tblImages where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'ImageAudits ContentID Delete'
|
||||
delete from ImageAudits where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'Details ContentID Delete'
|
||||
delete from Details where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'ZContents ContentID Delete'
|
||||
delete from ZContents where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'tblContents ContentID Delete'
|
||||
delete from tblContents where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'ContentAudits ContentID Delete'
|
||||
delete from ContentAudits where contentid in(select contentid from @CleanUp)
|
||||
PRINT 'Cleanup Complete'
|
||||
|
||||
|
30
PROMS/SQL Data Tools/CleanupAssociations.sql
Normal file
30
PROMS/SQL Data Tools/CleanupAssociations.sql
Normal file
@ -0,0 +1,30 @@
|
||||
-- Replace all associations with ROFSTID = 4
|
||||
Update Associations Set ROFSTID = 4
|
||||
-- Fix roimages
|
||||
Update ROImages set RODBID=2 where RODBID=1 and FileName Not In (Select FileName from roimages where RODBID=2)
|
||||
-- fix figures
|
||||
Update FF Set FF.ImageID = (select ImageID from ROImages RI1 where RI1.RODBID=2 and RI.FileName = RI1.FileName)
|
||||
from Figures FF join ROIMages RI ON FF.ImageID = RI.ImageID Where RODBID = 1
|
||||
Update FF Set FF.ROFSTID = 4 from figures FF where ImageID not in(select imageid from figures where ROFSTID = 4)
|
||||
-- remove unused roimages
|
||||
DELETE ROImages where RODBID=1
|
||||
-- remove unused Figures
|
||||
DELETE FROM Figures WHERE ROFSTID != 4-- Delete unused ROFSTs
|
||||
-- remove unused ROFSTs
|
||||
DELETE FROM ROFSTS WHERE ROFSTID != 4
|
||||
-- update ROUsages to point to RODBID = 2
|
||||
Update ROUSages set RODBID =2 where RODBID=1
|
||||
-- update DROUsages to point to RODBID = 2
|
||||
Update DROUSages set RODBID =2 where RODBID=1
|
||||
-- update tblContents Text
|
||||
EXEC('DISABLE TRIGGER tr_tblContents_Update ON tblContents')
|
||||
Update tblContents Set Text = Replace(TEXT,' 1[END>',' 2[END>') where Text like '% 1\[END>%' escape '\'
|
||||
EXEC('ENABLE TRIGGER tr_tblContents_Update ON tblContents')
|
||||
-- update tblGrids.Data
|
||||
EXEC('DISABLE TRIGGER tr_tblGrids_Update ON tblGrids')
|
||||
update tblGrids
|
||||
set Data = CAST(Replace(CAST([Data] as nvarchar(max)),' 1[END>',' 2[END>') as XML)
|
||||
where Cast([Data] as nvarchar(max)) like '% 1\[END>%' escape '\'
|
||||
EXEC('ENABLE TRIGGER tr_tblGrids_Update ON tblGrids')
|
||||
-- Remove unused RODBs
|
||||
Delete RODBs Where RODBID = 1
|
53
PROMS/SQL Data Tools/CleanupROUsagesByron.SQL
Normal file
53
PROMS/SQL Data Tools/CleanupROUsagesByron.SQL
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
VersionID : 14
|
||||
RofstID : 164
|
||||
RODBIDs : 2 RO
|
||||
|
||||
RODBID Change from 2 to 1
|
||||
*/
|
||||
EXECUTE [vesp_TurnChangeManagerOFF]
|
||||
GO
|
||||
-- Contents - replacing rodbid's in content records' link text, for the input version
|
||||
update contents set text = replace(text, ' 2[END>', ' 1[END>')
|
||||
where contentid in (
|
||||
select vi.contentid from vefn_getversionitems('14') vi
|
||||
join rousages ru on ru.contentid = vi.contentid
|
||||
where ru.rodbid = 2)
|
||||
|
||||
-- Grids - replacing rodbid's in grid records' link text
|
||||
update grids set data = cast(replace(cast(data as nvarchar(max)), ' 2[END>', ' 1[END>') as xml)
|
||||
where contentid in (
|
||||
select vi.contentid from vefn_getversionitems('14') vi
|
||||
join rousages ru on ru.contentid = vi.contentid
|
||||
where ru.rodbid = 2)
|
||||
|
||||
-- ROUsages - updating rousage records with correct rodbid
|
||||
update rousages set rodbid = 1
|
||||
where rodbid = 2 and contentid in (
|
||||
select vi.contentid from vefn_getversionitems('14') vi
|
||||
join rousages ru on ru.contentid = vi.contentid
|
||||
where ru.rodbid = 2)
|
||||
|
||||
-- DROUsages - updating rousage records with correct rodbid
|
||||
update drousages set rodbid = 1
|
||||
where rodbid = 2
|
||||
|
||||
delete from Figures where ROFstID = 164
|
||||
update Associations set ROFstID = 160 where ROFstID = 164
|
||||
delete from ROFsts where ROFstID = 164
|
||||
|
||||
-- ROFSTs - Update RODBID to 2 from 3
|
||||
update rofsts set rodbid = 1 where rodbid = 2
|
||||
|
||||
-- Associations - No Change
|
||||
-- ROImages - No Change
|
||||
-- Figures - Insert duplicate records for figures
|
||||
-- INSERT INTO [Figures] ([ROFstID],[ImageID],[Config],[DTS],[UserID])
|
||||
-- select 24,[ImageID],[Config],[DTS],[UserID] from [Figures] where ROFSTID = 23
|
||||
-- Remove unused RODBs
|
||||
Delete RODBs Where RODBID = 2
|
||||
GO
|
||||
EXECUTE [vesp_TurnChangeManagerON]
|
||||
GO
|
||||
|
||||
|
49
PROMS/SQL Data Tools/CleanupROUsagesGinna.SQL
Normal file
49
PROMS/SQL Data Tools/CleanupROUsagesGinna.SQL
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
VersionID : 6 Enhanced Background Documents
|
||||
RofstID : 24 2013-02-25 17:43:44.000
|
||||
RODBIDs : 3 RO D:\DATA\DDRIVE\VERGE\RO 97
|
||||
|
||||
RODBID Change from 3 to 1
|
||||
*/
|
||||
EXECUTE [vesp_TurnChangeManagerOFF]
|
||||
GO
|
||||
-- Contents - replacing rodbid's in content records' link text, for the input version
|
||||
update contents set text = replace(text, ' 3[END>', ' 2[END>')
|
||||
where contentid in (
|
||||
select vi.contentid from vefn_getversionitems('6') vi
|
||||
join rousages ru on ru.contentid = vi.contentid
|
||||
where ru.rodbid = 3)
|
||||
|
||||
-- Grids - replacing rodbid's in grid records' link text
|
||||
update grids set data = cast(replace(cast(data as nvarchar(max)), ' 3[END>', ' 2[END>') as xml)
|
||||
where contentid in (
|
||||
select vi.contentid from vefn_getversionitems('6') vi
|
||||
join rousages ru on ru.contentid = vi.contentid
|
||||
where ru.rodbid = 3)
|
||||
|
||||
-- ROUsages - updating rousage records with correct rodbid
|
||||
update rousages set rodbid = 2
|
||||
where rodbid = 3 and contentid in (
|
||||
select vi.contentid from vefn_getversionitems('6') vi
|
||||
join rousages ru on ru.contentid = vi.contentid
|
||||
where ru.rodbid = 3)
|
||||
|
||||
-- DROUsages - updating rousage records with correct rodbid
|
||||
update drousages set rodbid = 2
|
||||
where rodbid = 3
|
||||
|
||||
-- ROFSTs - Update RODBID to 2 from 3
|
||||
update rofsts set rodbid = 2 where rodbid = 3
|
||||
|
||||
-- Associations - No Change
|
||||
-- ROImages - No Change
|
||||
-- Figures - Insert duplicate records for figures
|
||||
INSERT INTO [Figures] ([ROFstID],[ImageID],[Config],[DTS],[UserID])
|
||||
select 24,[ImageID],[Config],[DTS],[UserID] from [Figures] where ROFSTID = 23
|
||||
-- Remove unused RODBs
|
||||
Delete RODBs Where RODBID = 3
|
||||
GO
|
||||
EXECUTE [vesp_TurnChangeManagerON]
|
||||
GO
|
||||
|
||||
|
23
PROMS/SQL Data Tools/Compression.sql
Normal file
23
PROMS/SQL Data Tools/Compression.sql
Normal file
@ -0,0 +1,23 @@
|
||||
select FormatID,Name,Description
|
||||
--,Data,PData,GData
|
||||
, isnull(x1StpSectLatData.value('@CompressSteps','varchar(255)'),isnull(x2StpSectLatData.value('@CompressSteps','varchar(255)'),x3StpSectLatData.value('@CompressSteps','varchar(255)'))) CompressSteps
|
||||
, isnull(x1StpSectLatData.value('@PartialStepCompression','varchar(255)'),isnull(x2StpSectLatData.value('@PartialStepCompression','varchar(255)'),x3StpSectLatData.value('@PartialStepCompression','varchar(255)'))) PartialStepCompression
|
||||
from (select FF.FormatID,FF.Name, FF.Description, Data,null PData,null GData
|
||||
from Formats FF
|
||||
where FormatID=1
|
||||
Union ALL
|
||||
select FF.FormatID,FF.Name, FF.Description, FF.Data, PF.Data PData,null GData
|
||||
from Formats FF
|
||||
Join Formats PF ON FF.ParentID=PF.FormatID
|
||||
Where PF.FormatID = 1 and FF.FormatID != 1
|
||||
Union ALL
|
||||
select FF.FormatID,FF.Name, FF.Description, FF.Data, PF.Data PData, GF.Data GData
|
||||
from Formats FF
|
||||
Join Formats PF ON FF.ParentID=PF.FormatID
|
||||
Join Formats GF ON PF.ParentID=GF.FormatID
|
||||
Where GF.FormatID = 1 and FF.FormatID != 1
|
||||
) T1
|
||||
cross apply data.nodes('/PlantFormat/FormatData/SectData/StepSectionData/StpSectLayData') t1StpSectLatData(x1StpSectLatData)
|
||||
outer apply pdata.nodes('/PlantFormat/FormatData/SectData/StepSectionData/StpSectLayData') t2StpSectLatData(x2StpSectLatData)
|
||||
outer apply gdata.nodes('/PlantFormat/FormatData/SectData/StepSectionData/StpSectLayData') t3StpSectLatData(x3StpSectLatData)
|
||||
Order by FormatID
|
13
PROMS/SQL Data Tools/Compression_stepcompression.sql
Normal file
13
PROMS/SQL Data Tools/Compression_stepcompression.sql
Normal file
@ -0,0 +1,13 @@
|
||||
select
|
||||
ff.formatID,ff.Name,ff.Description--,ff.Data
|
||||
--,pf.formatID,pf.Name,pf.Description
|
||||
--,gf.formatID,gf.Name,gf.Description
|
||||
, isnull(ffxStpSectLayData.value('@CompressSteps','varchar(5)'),isnull(pfxStpSectLayData.value('@CompressSteps','varchar(5)'),gfxStpSectLayData.value('@CompressSteps','varchar(5)'))) CompressSteps
|
||||
, isnull(ffxStpSectLayData.value('@PartialStepCompression','varchar(5)'),isnull(pfxStpSectLayData.value('@PartialStepCompression','varchar(5)'),gfxStpSectLayData.value('@PartialStepCompression','varchar(5)'))) PartialStepCompression
|
||||
from Formats FF
|
||||
Join Formats PF on PF.FormatID = ff.ParentID
|
||||
Join Formats GF on GF.FOrmatID = PF.ParentID
|
||||
cross apply ff.Data.nodes('//StpSectLayData') fftStpSectLayData(ffxStpSectLayData)
|
||||
cross apply pf.Data.nodes('//StpSectLayData') pftStpSectLayData(pfxStpSectLayData)
|
||||
cross apply gf.Data.nodes('//StpSectLayData') gftStpSectLayData(gfxStpSectLayData)
|
||||
order by ff.formatID
|
99
PROMS/SQL Data Tools/ConvertEnhanced.sql
Normal file
99
PROMS/SQL Data Tools/ConvertEnhanced.sql
Normal file
@ -0,0 +1,99 @@
|
||||
use veproms_BYR2
|
||||
GO
|
||||
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[ConvertEnhanced]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [ConvertEnhanced];
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[ConvertEnhanced]
|
||||
(
|
||||
@svid int,
|
||||
@bvid int,
|
||||
@Type varchar(1),
|
||||
@Source varchar(3),
|
||||
@Proc varchar(3)
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN TRY -- Try Block
|
||||
BEGIN TRANSACTION
|
||||
--
|
||||
update cc set cc.config = ah.newConfig
|
||||
from
|
||||
(
|
||||
select
|
||||
replace( case @Source when 'Yes' then t1.config else t2.config end ,'></Config>'
|
||||
,'><Enhanced Type="' + @Type + '" ItemID="' + CAST(case @Source when 'Yes' then t2.ItemID else t1.ItemID end as varchar(8)) + '" /></Config>') newConfig
|
||||
,t1.ContentID sourceID,t2.ContentID enhancedID from
|
||||
(
|
||||
select vi.VersionID,vi.ItemID,cc.ContentID,cc.Config,cc.Type,cc.Text,xHistory.value('@ProcName','nvarchar(8)') ProcName,xHistory.value('@RecID','nvarchar(8)') RecID
|
||||
from vefn_GetVersionItems(@svid) vi
|
||||
join (select ContentID,Type,Text,Config,CAST(Config as xml) xConfig from Contents where (@Proc = 'Yes' and type = 0) or (@Proc != 'Yes' and Type >= 10000)) cc on vi.ContentID = cc.ContentID
|
||||
cross apply xConfig.nodes('//History') tHistory(xHistory)
|
||||
) t1
|
||||
join
|
||||
(
|
||||
select vi.VersionID,vi.ItemID,cc.ContentID,cc.Config,cc.Type,cc.Text,xHistory.value('@ProcName','nvarchar(8)') ProcName,xHistory.value('@RecID','nvarchar(8)') RecID
|
||||
from vefn_GetVersionItems(@bvid) vi
|
||||
join (select ContentID,Type,Text,Config,CAST(Config as xml) xConfig from Contents where (@Proc = 'Yes' and type = 0) or (@Proc != 'Yes' and Type >= 10000)) cc on vi.ContentID = cc.ContentID
|
||||
cross apply xConfig.nodes('//History') tHistory(xHistory)
|
||||
) t2 on t1.ProcName = t2.ProcName and (@Proc = 'Yes' or (@Proc != 'Yes' and (SUBSTRING(t1.RecID,3,6) = SUBSTRING(t2.RecID,3,6) and LEFT(t2.RecID,2) = '0L')))
|
||||
) ah
|
||||
join Contents cc on case @Source when 'Yes' then ah.sourceID else ah.enhancedID end = cc.ContentID --
|
||||
IF( @@TRANCOUNT > 0 ) COMMIT
|
||||
END TRY
|
||||
BEGIN CATCH -- Catch Block
|
||||
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
|
||||
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
|
||||
EXEC vlnErrorHandler
|
||||
END CATCH
|
||||
GO
|
||||
exec vesp_TurnChangeManagerOFF
|
||||
go
|
||||
declare @svid int
|
||||
declare @bvid int
|
||||
--set variable for source
|
||||
select @svid = VersionID from vefn_GetVersionNames() where FolderName = 'Rev. 2 EOP Master Procedures'
|
||||
--set variable for background
|
||||
|
||||
select @Bvid = VersionID from vefn_GetVersionNames() where FolderName = 'Rev. 2 EOP Backgrounds'
|
||||
--update docversion for Background
|
||||
print 'BGDV-1'
|
||||
update docversions set config = replace(config,'></Config>',
|
||||
'><Enhanced Name="Background" Type="1" VersionID="' + cast(@bvid as varchar(25)) + '" PdfX="6" PdfToken="B"/></Config>')
|
||||
where VersionID =@svid
|
||||
print 'BGDV-2'
|
||||
update docversions set config = replace(config,'></Config>',
|
||||
'><Enhanced Name="Source" Type="0" VersionID="' + cast(@svid as varchar(25)) + '" PdfX="6" PdfToken="S"/></Config>')
|
||||
where VersionID =@bvid
|
||||
print 'BG-1'
|
||||
Exec ConvertEnhanced @svid,@bvid,'1','Yes','Yes'
|
||||
print 'BG-2'
|
||||
Exec ConvertEnhanced @svid,@bvid,'0','No','Yes'
|
||||
print 'BG-3'
|
||||
Exec ConvertEnhanced @svid,@bvid,'1','Yes','No'
|
||||
print 'BG-4'
|
||||
Exec ConvertEnhanced @svid,@bvid,'0','No','No'
|
||||
select @Bvid = VersionID from vefn_GetVersionNames() where FolderName = 'Rev. 2 EOP Deviations'
|
||||
--update docversion for Deviations
|
||||
print 'DDDV-1'
|
||||
update docversions set config = replace(config,'></Config>',
|
||||
'><Enhanced Name="Deviation" Type="2" VersionID="' + cast(@bvid as varchar(25)) + '" PdfX="20" PdfToken="D"/></Config>')
|
||||
where VersionID =@svid
|
||||
print 'DDDV-2'
|
||||
update docversions set config = replace(config,'></Config>',
|
||||
'><Enhanced Name="Source" Type="0" VersionID="' + cast(@svid as varchar(25)) + '" PdfX="6" PdfToken="S"/></Config>')
|
||||
where VersionID =@bvid
|
||||
print 'DD-1'
|
||||
Exec ConvertEnhanced @svid,@bvid,'2','Yes','Yes'
|
||||
print 'DD-2'
|
||||
Exec ConvertEnhanced @svid,@bvid,'0','No','Yes'
|
||||
print 'DD-3'
|
||||
Exec ConvertEnhanced @svid,@bvid,'2','Yes','No'
|
||||
print 'DD-4'
|
||||
Exec ConvertEnhanced @svid,@bvid,'0','No','No'
|
||||
GO
|
||||
exec vesp_TurnChangeManagerON
|
||||
go
|
||||
Use Master
|
||||
go
|
48
PROMS/SQL Data Tools/DeleteDisconnectedData.sql
Normal file
48
PROMS/SQL Data Tools/DeleteDisconnectedData.sql
Normal file
@ -0,0 +1,48 @@
|
||||
declare @UsedItems Table
|
||||
( itemid int primary key, contentID int )
|
||||
insert into @UsedItems
|
||||
Select ItemID, ContentID from vefn_GetVersionItemsIncludingDeleted('')
|
||||
|
||||
select 'Working Drafts' Query, FolderName,Dv.* from DocVersions DV
|
||||
JOIN VEFN_GetVersionNames() VN ON DV.VersionID = VN.VersionID
|
||||
|
||||
declare @DiscItems Table
|
||||
( itemid int primary key, ContentID int)
|
||||
insert into @DiscItems
|
||||
Select ItemID, II.ContentID from tblItems II
|
||||
Join tblContents CC ON CC.ContentID = II.ContentID
|
||||
where ItemID not in(select ItemID from @UsedItems)
|
||||
And CC.Type is not null
|
||||
|
||||
delete from [Revisions] where ItemID in (select itemid from @DiscItems)
|
||||
delete from [AnnotationAudits] where ItemID in (select itemid from @DiscItems)
|
||||
delete from [ItemAudits] where ItemID in (select itemid from @DiscItems)
|
||||
delete from [tblParts] where ItemID in (select itemid from @DiscItems)
|
||||
delete from [DocVersions] where ItemID in (select itemid from @DiscItems)
|
||||
delete from [PartAudits] where ItemID in (select itemid from @DiscItems)
|
||||
delete from [tblAnnotations] where ItemID in (select itemid from @DiscItems)
|
||||
|
||||
delete from [Details] where contentID in (select contentid from @DiscItems)
|
||||
delete from [ZContents] where contentID in (select contentid from @DiscItems)
|
||||
delete from [tblGrids] where contentID in (select contentid from @DiscItems)
|
||||
delete from [tblImages] where contentID in (select contentid from @DiscItems)
|
||||
delete from [ContentAudits] where contentID in (select contentid from @DiscItems)
|
||||
delete from [tblROUsages] where contentID in (select contentid from @DiscItems)
|
||||
delete from [EntryAudits] where contentID in (select contentid from @DiscItems)
|
||||
delete from [tblEntries] where contentID in (select contentid from @DiscItems)
|
||||
delete from [GridAudits] where contentID in (select contentid from @DiscItems)
|
||||
delete from [ImageAudits] where contentID in (select contentid from @DiscItems)
|
||||
delete from [ItemAudits] where contentID in (select contentid from @DiscItems)
|
||||
delete from [tblParts] where contentID in (select contentid from @DiscItems)
|
||||
delete from [PartAudits] where contentID in (select contentid from @DiscItems)
|
||||
delete from [ROUsageAudits] where contentID in (select contentid from @DiscItems)
|
||||
delete from [ztransitions] where transitionid in(select transitionid from [tblTransitions] where fromid in (select contentid from @DiscItems))
|
||||
delete from [ztransitions] where transitionid in(select transitionid from [tblTransitions] where toid in (select itemid from @DiscItems))
|
||||
delete from [ztransitions] where transitionid in(select transitionid from [tblTransitions] where rangeid in (select itemid from @DiscItems))
|
||||
delete from [tblTransitions] where fromid in (select contentid from @DiscItems)
|
||||
delete from [tblTransitions] where toid in (select itemid from @DiscItems)
|
||||
delete from [tblTransitions] where rangeid in (select itemid from @DiscItems)
|
||||
delete from [tblItems] where PreviousID in (select itemid from @DiscItems)
|
||||
delete from [tblItems] where ItemID in (select itemid from @DiscItems)
|
||||
delete from [tblItems] where contentID in (select contentid from @DiscItems)
|
||||
delete from [tblContents] where contentID in (select contentid from @DiscItems)
|
46
PROMS/SQL Data Tools/DisconnectGroups.sql
Normal file
46
PROMS/SQL Data Tools/DisconnectGroups.sql
Normal file
@ -0,0 +1,46 @@
|
||||
declare @UsedItems Table
|
||||
( itemid int primary key, contentID int )
|
||||
insert into @UsedItems
|
||||
Select ItemID, ContentID from [vefn_GetVersionItemsIncludingDeleted]('')
|
||||
|
||||
select 'Working Drafts' Query, FolderName,Dv.* from DocVersions DV
|
||||
JOIN VEFN_GetVersionNames() VN ON DV.VersionID = VN.VersionID
|
||||
|
||||
declare @DiscItems Table
|
||||
( itemid int primary key, ContentID int)
|
||||
insert into @DiscItems
|
||||
Select ItemID, II.ContentID from tblItems II
|
||||
Join tblContents CC ON CC.ContentID = II.ContentID
|
||||
where ItemID not in(select ItemID from @UsedItems)
|
||||
And CC.Type is not null
|
||||
|
||||
select 'Total Disconnected Items' Query, count(*) HowMany from @DiscItems
|
||||
--select COUNT(*) HowManyTotal from Items II
|
||||
--Join Contents CC ON CC.ContentID = II.ContentID
|
||||
--where ItemID in (select ItemID from @DiscItems)
|
||||
|
||||
-- Disconnected Groups
|
||||
select 'Disconnected Groups' Query, ItemID,II.ContentID, Type, replace(Number,'\u8209?','-') Num, Text, CC.UserID, CC.DTS
|
||||
, (select COUNT(*) from vefn_SiblingItems(ItemID,null))-1 Siblings
|
||||
, (select COUNT(*) from vefn_SiblingChildrenItems(ItemID))-1 SiblingChildren
|
||||
, (select MAX(DTS) from vefn_SiblingChildrenItems(ItemID) VI join Contents CC on VI.ContentID = CC.ContentID) ContentDTS
|
||||
, (select MAX(DTS) from vefn_SiblingChildrenItems(ItemID) VI join Items II on VI.ItemID = II.ItemID) ItemDTS
|
||||
, (select MIN(ItemID) from vefn_SiblingChildrenItems(ItemID)) MinItemID
|
||||
, (select MAX(ItemID) from vefn_SiblingChildrenItems(ItemID)) MaxItemID
|
||||
, (select COUNT(*) from transitions
|
||||
where fromid in(select ContentID from vefn_SiblingChildrenItems(ItemID))
|
||||
and toid in (select ItemID from @UsedItems)) FromDiscTrans
|
||||
, (select COUNT(*) from transitions
|
||||
where fromid in(select ContentID from @UsedItems)
|
||||
and toid in (select ItemID from vefn_SiblingChildrenItems(ItemID))) ToDiscTrans
|
||||
, (Select Count(*) from Annotations AA
|
||||
where AA.ItemID In (select ItemID from vefn_SiblingChildrenItems(II.ItemID))) Annotations
|
||||
, (Select Count(*) from ROUsages
|
||||
where ContentID In (select ContentID from vefn_SiblingChildrenItems(ItemID))) RefObjects
|
||||
, (Select Count(*) from Entries
|
||||
where ContentID In (select ContentID from vefn_SiblingChildrenItems(ItemID))) LibraryDocs
|
||||
from Items II
|
||||
Join Contents CC ON CC.ContentID = II.ContentID
|
||||
where ItemID in (select ItemID from @DiscItems)
|
||||
and PreviousID is null
|
||||
and ItemID not in (Select ItemID from Parts)
|
63
PROMS/SQL Data Tools/DisconnectedStepsandSections.sql
Normal file
63
PROMS/SQL Data Tools/DisconnectedStepsandSections.sql
Normal file
@ -0,0 +1,63 @@
|
||||
declare @UsedItems Table
|
||||
( itemid int primary key, contentID int )
|
||||
insert into @UsedItems
|
||||
Select ItemID, ContentID from vefn_GetVersionItems('')
|
||||
|
||||
declare @DiscItems Table
|
||||
( itemid int primary key, ContentID int)
|
||||
insert into @DiscItems
|
||||
Select ItemID, II.ContentID from Items II
|
||||
Join Contents CC ON CC.ContentID = II.ContentID
|
||||
where ItemID not in(select ItemID from @UsedItems)
|
||||
And CC.Type is not null
|
||||
|
||||
select * from @discitems
|
||||
|
||||
|
||||
--select COUNT(*) HowManyTotal from Items II
|
||||
--Join Contents CC ON CC.ContentID = II.ContentID
|
||||
--where ItemID in (select ItemID from @DiscItems)
|
||||
|
||||
-- Disconnected Groups
|
||||
select ItemID,II.ContentID, Type, Number, Text, CC.UserID, CC.DTS
|
||||
, (select COUNT(*) from vefn_SiblingItems(ItemID,null))-1 Siblings
|
||||
, (select COUNT(*) from vefn_SiblingChildrenItems(ItemID))-1 SiblingChildren
|
||||
, (select COUNT(*) from transitions
|
||||
where fromid in(select ContentID from vefn_SiblingChildrenItems(ItemID))
|
||||
and toid in (select ItemID from @UsedItems)) FromDiscTrans
|
||||
, (select COUNT(*) from transitions
|
||||
where fromid in(select ContentID from @UsedItems)
|
||||
and toid in (select ItemID from vefn_SiblingChildrenItems(ItemID))) ToDiscTrans
|
||||
, (Select Count(*) from Annotations AA
|
||||
where AA.ItemID In (select ItemID from vefn_SiblingChildrenItems(II.ItemID))) Annotations
|
||||
, (Select Count(*) from ROUsages
|
||||
where ContentID In (select ContentID from vefn_SiblingChildrenItems(ItemID))) RefObjects
|
||||
, (Select Count(*) from Entries
|
||||
where ContentID In (select ContentID from vefn_SiblingChildrenItems(ItemID))) LibraryDocs
|
||||
from Items II
|
||||
Join Contents CC ON CC.ContentID = II.ContentID
|
||||
where ItemID in (select ItemID from @DiscItems)
|
||||
and PreviousID is null
|
||||
and ItemID not in (Select ItemID from Parts)
|
||||
|
||||
select vnf.FolderName FromFolderName, FromID, dbo.ve_GetShortPathFromContentID(fromid)Source, vnt.FolderName ToFolderName, ToID, dbo.ve_GetShortPath(toid) Destination from Transitions TT
|
||||
left Join vefn_GetVersionItems('') VIF on VIF.ContentID = TT.FromID left JOIN vefn_GetVersionNames() VNF on VNF.versionID = VIF.VersionID
|
||||
left Join vefn_GetVersionItems('') VIT on VIT.Itemid =TT.ToID left JOIN vefn_GetVersionNames() VNT on VNT.versionID = VIT.VersionID
|
||||
where ToiD in(select itemID from @DiscItems) and FromiD in(select contentID from @UsedItems)
|
||||
|
||||
select vnf.foldername FromFolderName, FromID, dbo.ve_GetShortPathFromContentID(fromid)Source, vnt.foldername ToFolderName, ToID, dbo.ve_GetShortPath(toid) Destination from Transitions TT
|
||||
left Join vefn_GetVersionItems('') VIF on VIF.ContentID = TT.FromID left JOIN vefn_GetVersionNames() VNF on VNF.versionID = VIF.VersionID
|
||||
left Join vefn_GetVersionItems('') VIT on VIT.Itemid =TT.ToID left JOIN vefn_GetVersionNames() VNT on VNT.versionID = VIT.VersionID
|
||||
where ToiD in(select itemID from @UsedItems) and FromiD in(select contentID from @DiscItems)
|
||||
|
||||
select vnf.FolderName, AA.ItemID, dbo.ve_GetShortPath(AA.ItemID)Location , AA.SearchText from Annotations AA
|
||||
left Join vefn_GetVersionItems('') VIF on VIF.ItemID = AA.ItemID left JOIN vefn_GetVersionNames() VNF on VNF.versionID = VIF.VersionID
|
||||
where AA.ItemiD in(select itemID from @DiscItems)
|
||||
|
||||
select vnf.FolderName, RO.ContentID, dbo.ve_GetShortPathFromContentID(RO.ContentID)Location , RO.ROID from ROUsages RO
|
||||
left Join vefn_GetVersionItems('') VIF on VIF.ContentID = RO.ContentID left JOIN vefn_GetVersionNames() VNF on VNF.versionID = VIF.VersionID
|
||||
where RO.ContentID in(select ContentID from @DiscItems)
|
||||
|
||||
select vnf.FolderName, EE.ContentID, dbo.ve_GetShortPathFromContentID(EE.ContentID)Location , Doc.LibTitle from Entries EE Join Documents DOC ON EE.DocID=DOC.DocID
|
||||
left Join vefn_GetVersionItems('') VIF on VIF.ContentID = EE.ContentID left JOIN vefn_GetVersionNames() VNF on VNF.versionID = VIF.VersionID
|
||||
where EE.ContentID in(select ContentID from @DiscItems)
|
@ -0,0 +1,18 @@
|
||||
-- Create a Summary of various Links within Procedure text
|
||||
select StartCount,EndCount,StartStartCount,EndEndCount
|
||||
, case stat when 0 then 'Good - Matching Starts and Ends' when 1 then 'Bad - Multiple Starts' else 'Bad - Requires Manual Fix' end Status
|
||||
, Count(*) HowMany
|
||||
from (
|
||||
select ContentID, StartCount,EndCount,StartStartCount,EndEndCount
|
||||
, case when StartCount=EndCount and StartStartCount = 0 and EndEndCount = 0 then 0
|
||||
when StartCount = EndCount+StartStartCount and EndEndCount = 0 then 1
|
||||
else 2 end Stat
|
||||
from (
|
||||
select ContentID
|
||||
, (Len(text)-len(replace(text,'<START]','')))/7 StartCount
|
||||
, (Len(text)-len(replace(text,'[END>','')))/5 EndCount
|
||||
, (Len(text)-len(replace(text,'<START]<START]','')))/14 StartStartCount
|
||||
, (Len(text)-len(replace(text,'[END>[END>','')))/10 EndEndCount
|
||||
From Contents) T1 ) t2
|
||||
Group By Stat,StartCount,EndCount,StartStartCount,EndEndCount
|
||||
Order By Stat,StartStartCount,EndEndCount,abs(StartCount-EndCount),StartCount,EndCount
|
@ -0,0 +1,15 @@
|
||||
--Find Bad formatted links (Transitions or Referenced Objects) which can be fixed by running FixBadLinkFormatStartStart.sql
|
||||
select VN.* , Vi.ItemID, dbo.ve_GetShortPath(VI.ItemID) Location from vefn_GetVersionProcedureItems('') vi
|
||||
JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
JOIN Contents CC ON VI.ContentID = CC.ContentID
|
||||
where VI.ContentID IN(select ContentID from ( select ContentID, StartCount,EndCount,StartStartCount,EndEndCount
|
||||
, case when StartCount=EndCount and StartStartCount = 0 and EndEndCount = 0 then 0
|
||||
when StartCount = EndCount+StartStartCount and EndEndCount = 0 then 1
|
||||
else 2 end Stat
|
||||
from (
|
||||
select ContentID
|
||||
, (Len(text)-len(replace(text,'<START]','')))/7 StartCount
|
||||
, (Len(text)-len(replace(text,'[END>','')))/5 EndCount
|
||||
, (Len(text)-len(replace(text,'<START]<START]','')))/14 StartStartCount
|
||||
, (Len(text)-len(replace(text,'[END>[END>','')))/10 EndEndCount
|
||||
From Contents) T1 ) t2 Where Stat= 1) Order By vi.VersionId,ProcId,Location
|
@ -0,0 +1,12 @@
|
||||
-- Fix Occurences of Links (Transitions or Referenced Objects) where the Start tag is repeated
|
||||
update Contents set text = Replace(Text,'<START]<START]','<START]') where ContentID IN(select ContentID from ( select ContentID, StartCount,EndCount,StartStartCount,EndEndCount
|
||||
, case when StartCount=EndCount and StartStartCount = 0 and EndEndCount = 0 then 0
|
||||
when StartCount = EndCount+StartStartCount and EndEndCount = 0 then 1
|
||||
else 2 end Stat
|
||||
from (
|
||||
select ContentID
|
||||
, (Len(text)-len(replace(text,'<START]','')))/7 StartCount
|
||||
, (Len(text)-len(replace(text,'[END>','')))/5 EndCount
|
||||
, (Len(text)-len(replace(text,'<START]<START]','')))/14 StartStartCount
|
||||
, (Len(text)-len(replace(text,'[END>[END>','')))/10 EndEndCount
|
||||
From Contents) T1 ) t2 Where Stat= 1)
|
@ -0,0 +1,15 @@
|
||||
--Find Locations of Bad Links which must be corrected manually. Must Copy Step Text, delete step and add step
|
||||
select VN.* , Vi.ItemID, dbo.ve_GetShortPath(VI.ItemID) Location from vefn_GetVersionProcedureItems('') vi
|
||||
JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
JOIN Contents CC ON VI.ContentID = CC.ContentID
|
||||
where VI.ContentID IN(select ContentID from ( select ContentID, StartCount,EndCount,StartStartCount,EndEndCount
|
||||
, case when StartCount=EndCount and StartStartCount = 0 and EndEndCount = 0 then 0
|
||||
when StartCount = EndCount+StartStartCount and EndEndCount = 0 then 1
|
||||
else 2 end Stat
|
||||
from (
|
||||
select ContentID
|
||||
, (Len(text)-len(replace(text,'<START]','')))/7 StartCount
|
||||
, (Len(text)-len(replace(text,'[END>','')))/5 EndCount
|
||||
, (Len(text)-len(replace(text,'<START]<START]','')))/14 StartStartCount
|
||||
, (Len(text)-len(replace(text,'[END>[END>','')))/10 EndEndCount
|
||||
From Contents) T1 ) t2 Where Stat= 2) Order By vi.VersionId,ProcId,Location
|
14
PROMS/SQL Data Tools/FindAllHSPinROFST.sql
Normal file
14
PROMS/SQL Data Tools/FindAllHSPinROFST.sql
Normal file
@ -0,0 +1,14 @@
|
||||
declare @dbNames nvarchar(max)
|
||||
set @dbnames = 'VEPROMS_%'
|
||||
declare @CommandLine nvarchar(max)
|
||||
set quoted_identifier off -- Allows single quotes to be used in the query'
|
||||
set @CommandLine = "
|
||||
select Count(*) HowMany from ~rofsts where rolookup like '%@HSP(%'
|
||||
"
|
||||
set quoted_identifier on
|
||||
declare @CommandLines nvarchar(max)
|
||||
select @CommandLines = Coalesce(@CommandLines + ' UNION' + char(10), '') + 'select ''' + Name + ''' DBName, * from ( ' + Replace(Replace(@CommandLine,'~','{Name}.dbo.'),'{Name}',Name) + ') T1'
|
||||
from Sys.Databases where name like @dbNames and name not like '%test'
|
||||
Set @CommandLines = 'Select * from ( ' +@CommandLines + ') t2 '--where HowMany > 0'
|
||||
print @CommandLines
|
||||
EXEC SP_EXECUTESQL @CommandLines
|
15
PROMS/SQL Data Tools/FindBadLinkFormatManualFixRequired.sql
Normal file
15
PROMS/SQL Data Tools/FindBadLinkFormatManualFixRequired.sql
Normal file
@ -0,0 +1,15 @@
|
||||
--Find Locations of Bad Links which must be corrected manually. Must Copy Step Text, delete step and add step
|
||||
select VN.* , Vi.ItemID, dbo.ve_GetShortPath(VI.ItemID) Location from vefn_GetVersionProcedureItems('') vi
|
||||
JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
JOIN Contents CC ON VI.ContentID = CC.ContentID
|
||||
where VI.ContentID IN(select ContentID from ( select ContentID, StartCount,EndCount,StartStartCount,EndEndCount
|
||||
, case when StartCount=EndCount and StartStartCount = 0 and EndEndCount = 0 then 0
|
||||
when StartCount = EndCount+StartStartCount and EndEndCount = 0 then 1
|
||||
else 2 end Stat
|
||||
from (
|
||||
select ContentID
|
||||
, (Len(text)-len(replace(text,'<START]','')))/7 StartCount
|
||||
, (Len(text)-len(replace(text,'[END>','')))/5 EndCount
|
||||
, (Len(text)-len(replace(text,'<START]<START]','')))/14 StartStartCount
|
||||
, (Len(text)-len(replace(text,'[END>[END>','')))/10 EndEndCount
|
||||
From Contents) T1 ) t2 Where Stat= 2) Order By vi.VersionId,ProcId,Location
|
15
PROMS/SQL Data Tools/FindBadLinkFormatStartStart.sql
Normal file
15
PROMS/SQL Data Tools/FindBadLinkFormatStartStart.sql
Normal file
@ -0,0 +1,15 @@
|
||||
--Find Bad formatted links (Transitions or Referenced Objects) which can be fix by running FixBadLinkFormatStartStart.sql
|
||||
select VN.* , Vi.ItemID, dbo.ve_GetShortPath(VI.ItemID) Location from vefn_GetVersionProcedureItems('') vi
|
||||
JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
JOIN Contents CC ON VI.ContentID = CC.ContentID
|
||||
where VI.ContentID IN(select ContentID from ( select ContentID, StartCount,EndCount,StartStartCount,EndEndCount
|
||||
, case when StartCount=EndCount and StartStartCount = 0 and EndEndCount = 0 then 0
|
||||
when StartCount = EndCount+StartStartCount and EndEndCount = 0 then 1
|
||||
else 2 end Stat
|
||||
from (
|
||||
select ContentID
|
||||
, (Len(text)-len(replace(text,'<START]','')))/7 StartCount
|
||||
, (Len(text)-len(replace(text,'[END>','')))/5 EndCount
|
||||
, (Len(text)-len(replace(text,'<START]<START]','')))/14 StartStartCount
|
||||
, (Len(text)-len(replace(text,'[END>[END>','')))/10 EndEndCount
|
||||
From Contents) T1 ) t2 Where Stat= 1) Order By vi.VersionId,ProcId,Location
|
6
PROMS/SQL Data Tools/FindBadROUsageReferences.sql
Normal file
6
PROMS/SQL Data Tools/FindBadROUsageReferences.sql
Normal file
@ -0,0 +1,6 @@
|
||||
select distinct vn.*,t1.contentid from (
|
||||
select gg.*, len(cast (data as nvarchar(max))) - len(replace( cast (data as nvarchar(max)),':ReferencedObject:',':ReferencedObject')) ros from grids gg
|
||||
join ROUsages ru on gg.ContentID = ru.ContentID where cast (data as nvarchar( max)) not like '%:' + cast (rousageid as nvarchar(10)) + ' %') T1
|
||||
join vefn_GetVersionItems('') vi on vi.ContentID = t1.ContentID
|
||||
join vefn_GetVersionNames() vn on vn.VersionID = vi.VersionID
|
||||
where ros > 0
|
11
PROMS/SQL Data Tools/FindLastHLSwithRNOsubstep.sql
Normal file
11
PROMS/SQL Data Tools/FindLastHLSwithRNOsubstep.sql
Normal file
@ -0,0 +1,11 @@
|
||||
select ii.ItemID, dbo.ve_GetShortPath(pr.itemid) location, vn.* from items ii
|
||||
join vefn_GetVersionItems('') vi on vi.ItemID = ii.ItemID
|
||||
join vefn_GetVersionNames() vn on vn.VersionID = vi.VersionID
|
||||
join contents cc on cc.ContentID = ii.contentid
|
||||
join parts pp on pp.ContentID = cc.ContentID and pp.FromType = 5
|
||||
join items ir on ir.ItemID = pp.ItemID
|
||||
join parts pr on pr.ContentID = ir.ContentID and pr.FromType = 6
|
||||
left join parts ps on ps.ContentID = cc.ContentID and ps.FromType = 6
|
||||
where ii.PreviousID is not null and ii.itemid not in (select PreviousID from items where PreviousID is not null)
|
||||
and cc.type in (20002, 20003, 20009, 20018, 20040, 20041) and ps.ContentID is null
|
||||
and dbo.ve_GetShortPath(pr.itemid) not like '%purpose%'
|
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
|
||||
|
7
PROMS/SQL Data Tools/FindMatchingTransitionIDs.sql
Normal file
7
PROMS/SQL Data Tools/FindMatchingTransitionIDs.sql
Normal file
@ -0,0 +1,7 @@
|
||||
select CTT.*, TT.* From (select ContentID FromID, TransitionID, TranType, ToID, RangeID, DTS from Contents cc
|
||||
cross apply vefn_FindTransitions(cc.Text)
|
||||
where cc.Text like '%Link:Transition%') CTT
|
||||
JOIN VEFN_GetVersionProcedureItems('') VI ON VI.ContentID = CTT.FromID
|
||||
JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
left Join Transitions TT on TT.TransitionID = case when CTT.TransitionID like '<%' then 0 else cast(CTT.TransitionID as int) end
|
||||
Where TT.TransitionID is not null and TT.FromID = CTT.FromID or TT.ToID = CTT.ToID
|
7
PROMS/SQL Data Tools/FindMissMatchTransitionIDs.sql
Normal file
7
PROMS/SQL Data Tools/FindMissMatchTransitionIDs.sql
Normal file
@ -0,0 +1,7 @@
|
||||
select CTT.*, TT.* From (select ContentID FromID, TransitionID, TranType, ToID, RangeID, DTS from Contents cc
|
||||
cross apply vefn_FindTransitions(cc.Text)
|
||||
where cc.Text like '%Link:Transition%') CTT
|
||||
JOIN VEFN_GetVersionProcedureItems('') VI ON VI.ContentID = CTT.FromID
|
||||
JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
left Join Transitions TT on TT.TransitionID = case when CTT.TransitionID like '<%' then 0 else cast(CTT.TransitionID as int) end
|
||||
Where TT.TransitionID is not null and TT.FromID != CTT.FromID or TT.ToID != CTT.ToID
|
7
PROMS/SQL Data Tools/FindMissingTransitionIDs.sql
Normal file
7
PROMS/SQL Data Tools/FindMissingTransitionIDs.sql
Normal file
@ -0,0 +1,7 @@
|
||||
select CTT.* From (select ContentID FromID, TransitionID, TranType, ToID, RangeID, DTS from Contents cc
|
||||
cross apply vefn_FindTransitions(cc.Text)
|
||||
where cc.Text like '%Link:Transition%') CTT
|
||||
JOIN VEFN_GetVersionProcedureItems('') VI ON VI.ContentID = CTT.FromID
|
||||
JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
left Join Transitions TT on TT.TransitionID = case when CTT.TransitionID like '<%' then 0 else cast(CTT.TransitionID as int) end
|
||||
Where TT.TransitionID is null
|
24
PROMS/SQL Data Tools/FindROProblems.sql
Normal file
24
PROMS/SQL Data Tools/FindROProblems.sql
Normal file
@ -0,0 +1,24 @@
|
||||
-- ROUsages
|
||||
select vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, rf.dts, rd.Roname, rd.folderpath, ru.rodbid urodbid, count (*) howmany
|
||||
from vefn_getversionnames() vn
|
||||
join vefn_getversionitems('') vi on vn.versionid = vi.versionid
|
||||
join rousages ru on ru.contentid = vi.contentid
|
||||
join associations aa on aa.versionid = vn.versionid
|
||||
join rofsts rf on rf.rofstid = aa.rofstid
|
||||
join rodbs rd on rf.rodbid = rd.rodbid
|
||||
where rd.rodbid <> ru.rodbid
|
||||
group by vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, rf.dts, rd.Roname, rd.folderpath, ru.rodbid
|
||||
order by rf.dts
|
||||
|
||||
-- DROUsages
|
||||
select vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, rf.dts, rd.Roname, rd.folderpath, dru.rodbid urodbid, count (*) howmany
|
||||
from vefn_getversionnames() vn
|
||||
join vefn_getversionitems('') vi on vn.versionid = vi.versionid
|
||||
join entries ee on ee.ContentID = vi.ContentID
|
||||
join drousages dru on dru.docid = ee.docid
|
||||
join associations aa on aa.versionid = vn.versionid
|
||||
join rofsts rf on rf.rofstid = aa.rofstid
|
||||
join rodbs rd on rf.rodbid = rd.rodbid
|
||||
where rd.rodbid <> dru.rodbid
|
||||
group by vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, rf.dts, rd.Roname, rd.folderpath, dru.rodbid
|
||||
order by rf.dts
|
24
PROMS/SQL Data Tools/FindROStatus.sql
Normal file
24
PROMS/SQL Data Tools/FindROStatus.sql
Normal file
@ -0,0 +1,24 @@
|
||||
-- ROUsages
|
||||
select 'rousages' sourcetable,vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, rf.dts, rd.Roname, rd.folderpath, ru.rodbid urodbid, count (*) howmany
|
||||
from vefn_getversionnames() vn
|
||||
join vefn_getversionitems('') vi on vn.versionid = vi.versionid
|
||||
join rousages ru on ru.contentid = vi.contentid
|
||||
join associations aa on aa.versionid = vn.versionid
|
||||
join rofsts rf on rf.rofstid = aa.rofstid
|
||||
join rodbs rd on rf.rodbid = rd.rodbid
|
||||
--where rd.rodbid <> ru.rodbid
|
||||
group by vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, rf.dts, rd.Roname, rd.folderpath, ru.rodbid
|
||||
order by rf.dts
|
||||
|
||||
-- DROUsages
|
||||
select 'drousages' sourcetable,vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, rf.dts, rd.Roname, rd.folderpath, dru.rodbid urodbid, count (*) howmany
|
||||
from vefn_getversionnames() vn
|
||||
join vefn_getversionitems('') vi on vn.versionid = vi.versionid
|
||||
join entries ee on ee.ContentID = vi.ContentID
|
||||
join drousages dru on dru.docid = ee.docid
|
||||
join associations aa on aa.versionid = vn.versionid
|
||||
join rofsts rf on rf.rofstid = aa.rofstid
|
||||
join rodbs rd on rf.rodbid = rd.rodbid
|
||||
--where rd.rodbid <> dru.rodbid
|
||||
group by vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, rf.dts, rd.Roname, rd.folderpath, dru.rodbid
|
||||
order by rf.dts
|
3
PROMS/SQL Data Tools/FindROTables.sql
Normal file
3
PROMS/SQL Data Tools/FindROTables.sql
Normal file
@ -0,0 +1,3 @@
|
||||
select * from grids gg
|
||||
Join Contents CC ON GG.ContentID = CC.ContentID where cc.contentid in (select contentID from rousages)
|
||||
And cast(Data as varchar(max)) like '%<IsRoTable>True</IsRoTable>%'
|
1
PROMS/SQL Data Tools/FindSQLVersion.sql
Normal file
1
PROMS/SQL Data Tools/FindSQLVersion.sql
Normal file
@ -0,0 +1 @@
|
||||
RESTORE HEADERONLY FROM DISK = 'C:\Folder Shares\04 VEPROMS FILES\Active Project Files\'
|
@ -0,0 +1 @@
|
||||
select * from Contents where type in(20021,20023,20026)
|
12
PROMS/SQL Data Tools/FindSectionsAndSteps_CalvertSTPs.sql
Normal file
12
PROMS/SQL Data Tools/FindSectionsAndSteps_CalvertSTPs.sql
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
select itemid, contentid,foldername,location, text,xConfig, ISNULL(xSubSection.value('@Edit','varchar(1)'),'N') EditSteps
|
||||
from (
|
||||
select itemid, vi.contentid, vn.foldername,dbo.ve_getshortpath(itemid) location, text, cast(config as xml) xConfig
|
||||
from vefn_getVersionItems('') VI
|
||||
join vefn_getversionnames() VN ON vn.versionid =vi.versionid
|
||||
join contents CC ON CC.Contentid = vi.contentid
|
||||
Where VI.ContentID in(Select ContentID from Parts where FromType = 2) -- Sections
|
||||
And VI.ContentID in(Select ContentID from Parts where FromType = 6) -- Steps
|
||||
) AH
|
||||
outer apply xConfig.nodes('//SubSection') tSubSection(xSubSection)
|
||||
--where xSubSection.value('@Edit','varchar(1)') is not null
|
@ -0,0 +1,2 @@
|
||||
select dbo.ve_GetShortPathFromContentID(GG.ContentID) Location from grids GG
|
||||
where cast(data as nvarchar(max)) like '%{\f1\fnil\fcharset0 Courier New;}%'
|
5
PROMS/SQL Data Tools/FindStrangeSectionTitles.sql
Normal file
5
PROMS/SQL Data Tools/FindStrangeSectionTitles.sql
Normal file
@ -0,0 +1,5 @@
|
||||
select dbo.ve_GetShortPathFromContentID(CC.ContentID) Location, substring(text,76,20) Part1, ContentID, Text
|
||||
from contents cc
|
||||
where type between 10000 and 19999
|
||||
--and text Like '%WCNS%' or
|
||||
and substring(text,72,5) like ' [A-Z]'
|
9
PROMS/SQL Data Tools/FindStrangeTables.sql
Normal file
9
PROMS/SQL Data Tools/FindStrangeTables.sql
Normal file
@ -0,0 +1,9 @@
|
||||
select VN.VersionID, FolderName, VI.ItemID, PP.FromType, IC.PreviousID ,ii.ItemID NextID, dbo.ve_GetShortPathFromContentID(CC.ContentID) Location from Contents CC
|
||||
JOIN VEFN_GetVersionProcedureItems('') VI ON VI.ContentID = CC.ContentID
|
||||
JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
Join Grids GG ON GG.ContentID=CC.ContentID
|
||||
Join Items IC on VI.ItemID = IC.ItemID
|
||||
Left Join Parts PP ON VI.ItemId = PP.ItemID
|
||||
Left Join Items II on II.PreviousID = VI.ItemID
|
||||
where Type not in (20008,20010,20033,20034)
|
||||
order by versionid, VI.ItemID
|
3
PROMS/SQL Data Tools/FindTablesWithDuplicateROUsages.sql
Normal file
3
PROMS/SQL Data Tools/FindTablesWithDuplicateROUsages.sql
Normal file
@ -0,0 +1,3 @@
|
||||
select *, case when cast(data as nvarchar(max)) like '%mergedranges%' then 'true' else 'false' end merged from Grids GG
|
||||
Join ROUsages RU ON RU.ContentID =GG.ContentID
|
||||
where cast(data as nvarchar(max)) like '%:' + cast(rousageid as varchar(10)) + '%:' + cast(rousageid as varchar(10)) + '%'
|
16
PROMS/SQL Data Tools/FindTransitionsToUneditableStepText.sql
Normal file
16
PROMS/SQL Data Tools/FindTransitionsToUneditableStepText.sql
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
select YY.* from (
|
||||
select XX.ItemID from (
|
||||
select ItemID from Parts
|
||||
where FromType = 6 and ContentID IN(select pp.contentid
|
||||
--,xSubSection.value('@Edit','varchar(1)') Editable
|
||||
from parts pp
|
||||
join (select Contentid, cast(config as xml) xConfig from contents) CC ON CC.ContentID= pp.ContentID
|
||||
outer apply xConfig.nodes('//SubSection') tSubSection(xSubSection)
|
||||
where fromtype in (2,6)
|
||||
and isnull(xSubSection.value('@Edit','varchar(1)'),'N')='N'
|
||||
group by pp.contentid
|
||||
having count(*) > 1) ) ah
|
||||
Cross Apply vefn_SiblingItems(ah.ItemID,null) XX
|
||||
Join Contents CC ON CC.ContentID=XX.ContentID) AH
|
||||
Cross Apply vefn_FindExternalTransitions(ItemID) YY
|
14
PROMS/SQL Data Tools/FindUneditableStepText.sql
Normal file
14
PROMS/SQL Data Tools/FindUneditableStepText.sql
Normal file
@ -0,0 +1,14 @@
|
||||
select XX.*, CC.Text from (
|
||||
select ItemID from Parts
|
||||
where FromType = 6 and ContentID IN(select pp.contentid
|
||||
--,xSubSection.value('@Edit','varchar(1)') Editable
|
||||
from parts pp
|
||||
join (select Contentid, cast(config as xml) xConfig from contents) CC ON CC.ContentID= pp.ContentID
|
||||
outer apply xConfig.nodes('//SubSection') tSubSection(xSubSection)
|
||||
where fromtype in (2,6)
|
||||
and isnull(xSubSection.value('@Edit','varchar(1)'),'N')='N'
|
||||
group by pp.contentid
|
||||
having count(*) > 1) ) ah
|
||||
Cross Apply vefn_SiblingItems(ah.ItemID,null) XX
|
||||
Join Contents CC ON CC.ContentID=XX.ContentID
|
||||
order by xx.ItemID
|
@ -0,0 +1,2 @@
|
||||
select * from contents where text like '%\\v0 \.\\v%' escape '\'
|
||||
|
12
PROMS/SQL Data Tools/FixBadLinkFormatStartStart.sql
Normal file
12
PROMS/SQL Data Tools/FixBadLinkFormatStartStart.sql
Normal file
@ -0,0 +1,12 @@
|
||||
-- Fix Occurences of Links (Trnasitions or Referenced Objects) where the Start tag ins repeated
|
||||
update Contents set text = Replace(Text,'<START]<START]','<START]') where ContentID IN(select ContentID from ( select ContentID, StartCount,EndCount,StartStartCount,EndEndCount
|
||||
, case when StartCount=EndCount and StartStartCount = 0 and EndEndCount = 0 then 0
|
||||
when StartCount = EndCount+StartStartCount and EndEndCount = 0 then 1
|
||||
else 2 end Stat
|
||||
from (
|
||||
select ContentID
|
||||
, (Len(text)-len(replace(text,'<START]','')))/7 StartCount
|
||||
, (Len(text)-len(replace(text,'[END>','')))/5 EndCount
|
||||
, (Len(text)-len(replace(text,'<START]<START]','')))/14 StartStartCount
|
||||
, (Len(text)-len(replace(text,'[END>[END>','')))/10 EndEndCount
|
||||
From Contents) T1 ) t2 Where Stat= 1)
|
32
PROMS/SQL Data Tools/FixLibDocs.sql
Normal file
32
PROMS/SQL Data Tools/FixLibDocs.sql
Normal file
@ -0,0 +1,32 @@
|
||||
declare @ld as table
|
||||
(
|
||||
DocID int,
|
||||
DocRank int
|
||||
)
|
||||
insert into @ld
|
||||
select DOCid, dense_rank() OVER(ORDER BY DOCCONTENT) AS DocRank
|
||||
from documents
|
||||
where libtitle != ''
|
||||
|
||||
declare @mld as table
|
||||
(
|
||||
DocRank int primary key,
|
||||
MinDocID int
|
||||
)
|
||||
insert into @mld
|
||||
select DocRank, min(DocID) MinDocID from @ld Group by DocRank
|
||||
|
||||
declare @trans as table
|
||||
(
|
||||
DocID int primary key,
|
||||
MinDocID int
|
||||
)
|
||||
Insert into @Trans
|
||||
Select DocID,MinDocID from @ld ld
|
||||
Join @mld mld on mld.docrank = ld.docrank
|
||||
where MinDocID != DocID
|
||||
order by ld.DocRank
|
||||
Update EE set DocID = MinDocID from entries EE
|
||||
Join @trans TT on EE.DocID = TT.DocID
|
||||
|
||||
Delete from Documents where DocID Not in (Select DocID From Entries)
|
@ -0,0 +1,12 @@
|
||||
INSERT INTO [dbo].[Figures]
|
||||
([ROFstID]
|
||||
,[ImageID]
|
||||
,[Config]
|
||||
,[DTS]
|
||||
,[UserID])
|
||||
Select 76
|
||||
,[ImageID]
|
||||
,[Config]
|
||||
,[DTS]
|
||||
,[UserID] from FIgures where ROFSTID=74
|
||||
|
123
PROMS/SQL Data Tools/FixROProblems.sql
Normal file
123
PROMS/SQL Data Tools/FixROProblems.sql
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
Volian Enterprises, Inc.
|
||||
Script to fix RO Problems
|
||||
*/
|
||||
/* This is equivalent to the FindROProblems query
|
||||
select vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, ru.rodbid Urodbid, Count(*) Problems
|
||||
from vefn_getversionnames() vn
|
||||
join vefn_getversionitems('') vi on vn.versionid = vi.versionid
|
||||
join rousages ru on ru.contentid = vi.contentid
|
||||
join associations aa on aa.versionid = vn.versionid
|
||||
join rofsts rf on rf.rofstid = aa.rofstid
|
||||
where rf.rodbid <> ru.rodbid
|
||||
group by vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, ru.rodbid
|
||||
|
||||
select vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, dru.rodbid Urodbid, Count(*) Problems
|
||||
from vefn_getversionnames() vn
|
||||
join vefn_getversionitems('') vi on vn.versionid = vi.versionid
|
||||
join entries ee on ee.contentID = vi.contentID
|
||||
join drousages dru on dru.docid = ee.docid
|
||||
join associations aa on aa.versionid = vn.versionid
|
||||
join rofsts rf on rf.rofstid = aa.rofstid
|
||||
where rf.rodbid <> dru.rodbid
|
||||
group by vn.versionid, ParentName,FolderName, aa.rofstid, rf.rodbid, dru.rodbid
|
||||
GO
|
||||
*/
|
||||
EXECUTE [vesp_TurnChangeManagerOFF]
|
||||
GO
|
||||
|
||||
PRINT 'Build @ProblemROUsages'
|
||||
DECLARE @ProblemROUsages table(
|
||||
ROUsageID int primary key,
|
||||
ContentID int,
|
||||
RODBID int,
|
||||
URODBID int
|
||||
)
|
||||
Insert Into @ProblemROUsages
|
||||
select ru.ROUsageID, RU.ContentID, rf.rodbid, ru.rodbid Urodbid
|
||||
from vefn_getversionnames() vn
|
||||
join vefn_getversionitems('') vi on vn.versionid = vi.versionid
|
||||
join rousages ru on ru.contentid = vi.contentid
|
||||
join associations aa on aa.versionid = vn.versionid
|
||||
join rofsts rf on rf.rofstid = aa.rofstid
|
||||
where rf.rodbid <> ru.rodbid
|
||||
|
||||
--select * from @ProblemROUsages
|
||||
|
||||
PRINT 'Build @ProblemDROUsages'
|
||||
DECLARE @ProblemDROUsages table(
|
||||
DROUsageID int primary key,
|
||||
RODBID int,
|
||||
URODBID int
|
||||
)
|
||||
Insert Into @ProblemDROUsages
|
||||
select distinct dru.dROUsageID, rf.rodbid, dru.rodbid Urodbid
|
||||
from vefn_getversionnames() vn
|
||||
join vefn_getversionitems('') vi on vn.versionid = vi.versionid
|
||||
join entries ee on ee.ContentID=vi.ContentID
|
||||
join drousages dru on dru.docid = ee.DocID
|
||||
join associations aa on aa.versionid = vn.versionid
|
||||
join rofsts rf on rf.rofstid = aa.rofstid
|
||||
where rf.rodbid <> dru.rodbid
|
||||
|
||||
--Select * from @ProblemDROUsages
|
||||
|
||||
|
||||
-- Contents - replacing rodbid's in content records' link text, for the input version
|
||||
PRINT 'Process Contents'
|
||||
update CC
|
||||
set text = replace(text,
|
||||
' ' + cast(pru.URODBID as nvarchar(10)) + '[END>',
|
||||
' ' + cast(pru.RODBID as nvarchar(10)) + '[END>')
|
||||
from contents CC join @ProblemROUsages PRU ON CC.ContentID = PRU.ContentID
|
||||
|
||||
|
||||
-- Grids - replacing rodbid's in grid records' link text
|
||||
PRINT 'Process Grids'
|
||||
update GG
|
||||
set data = cast(replace(cast(data as nvarchar(max)),
|
||||
' ' + cast(pru.URODBID as nvarchar(10)) + '[END>',
|
||||
' ' + cast(pru.RODBID as nvarchar(10)) + '[END>') as xml)
|
||||
from grids GG join @ProblemROUsages PRU ON GG.ContentID = PRU.ContentID
|
||||
|
||||
-- ROUsages - updating rousage records with correct rodbid
|
||||
PRINT 'Process ROUsages'
|
||||
update RU
|
||||
set rodbid = PRU.rodbid
|
||||
From rousages RU Join @ProblemROUsages PRU ON RU.ROUsageID=pru.ROUsageID
|
||||
|
||||
-- DROUsages - updating rousage records with correct rodbid
|
||||
PRINT 'Process DROUsages'
|
||||
update DRU
|
||||
set rodbid = PDRU.rodbid
|
||||
From drousages DRU Join @ProblemDROUsages PDRU ON DRU.DROUsageID=pdru.DROUsageID
|
||||
|
||||
-- ROFSTs - Update RODBID to 2 from 3
|
||||
-- Associations - No Change
|
||||
-- ROImages - No Change
|
||||
-- Figures - Insert duplicate records for figures
|
||||
-- Remove unused RODBs
|
||||
GO
|
||||
EXECUTE [vesp_TurnChangeManagerON]
|
||||
GO
|
||||
/*
|
||||
This is equivalent to FindROProblems query
|
||||
select vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, ru.rodbid Urodbid, Count(*) Problems
|
||||
from vefn_getversionnames() vn
|
||||
join vefn_getversionitems('') vi on vn.versionid = vi.versionid
|
||||
join rousages ru on ru.contentid = vi.contentid
|
||||
join associations aa on aa.versionid = vn.versionid
|
||||
join rofsts rf on rf.rofstid = aa.rofstid
|
||||
where rf.rodbid <> ru.rodbid
|
||||
group by vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, ru.rodbid
|
||||
|
||||
select vn.versionid, ParentName, FolderName, aa.rofstid, rf.rodbid, dru.rodbid Urodbid, Count(*) Problems
|
||||
from vefn_getversionnames() vn
|
||||
join vefn_getversionitems('') vi on vn.versionid = vi.versionid
|
||||
join entries ee on ee.contentID = vi.contentID
|
||||
join drousages dru on dru.docid = ee.docid
|
||||
join associations aa on aa.versionid = vn.versionid
|
||||
join rofsts rf on rf.rofstid = aa.rofstid
|
||||
where rf.rodbid <> dru.rodbid
|
||||
group by vn.versionid, ParentName,FolderName, aa.rofstid, rf.rodbid, dru.rodbid
|
||||
GO*/
|
30
PROMS/SQL Data Tools/GetRODBsAndROFSTsAndAssociations.sql
Normal file
30
PROMS/SQL Data Tools/GetRODBsAndROFSTsAndAssociations.sql
Normal file
@ -0,0 +1,30 @@
|
||||
-- RODBs
|
||||
SELECT RODBID, ROName, FolderPath From RODBS
|
||||
-- ROFSTs
|
||||
Select ROFSTID, RODBID, DTS, len(ROLookup) Size, len(ROLookup)/1024 KBS from ROFSTS
|
||||
-- Associations
|
||||
Select AA.ROFSTID, RF.RODBID, DV.VersionID, FF.Name
|
||||
from associations AA
|
||||
Join ROFSTS RF ON AA.ROFSTID = RF.ROFSTID
|
||||
Join DocVersions DV ON DV.VersionID = AA.VersionID
|
||||
Join Folders FF ON Dv.FolderID = FF.FolderID
|
||||
--
|
||||
select RODBID,Count(*) HowMany from ROUSages Group by RODBID
|
||||
select RODBID,Count(*) HowMany from DROUSages Group by RODBID
|
||||
select ImageID, RODBID,FileName from ROIMAGES
|
||||
select FF.ImageID, RODBID from Figures FF Join ROImages RI ON RI.ImageID = FF.ImageID
|
||||
/*
|
||||
--Update RODBs Set FolderPath = 'C:\Plant\VEHLP\RO' where RODBID = 1
|
||||
Update Associations Set ROFSTID = 4
|
||||
delete from Figures where ROFSTID != 4
|
||||
DELETE From ROFSTS where ROFSTID != 4
|
||||
update roFSTs set RODBID = 1
|
||||
Update ROUSages set RODBID =1 where RODBID=2
|
||||
Update Contents Set Text = Replace(TEXT,' 2[END>',' 1[END>') where Text like '% 2\[END>%' escape '\'
|
||||
Update DROUSages set RODBID =1 where RODBID=2
|
||||
Update ROImages set RODBID=1 where RODBID=2 and FileName Not In (Select FileName from roimages where RODBID=1)
|
||||
Update FF Set FF.ImageID = (select ImageID from ROImages RI1 where RI1.RODBID=1 and RI.FileName = RI1.FileName)
|
||||
from Figures FF join ROIMages RI ON FF.ImageID = RI.ImageID Where RODBID = 2
|
||||
DELETE ROImages where RODBID=2
|
||||
Delete RODBs Where RODBID = 2
|
||||
*/
|
5
PROMS/SQL Data Tools/GetVersionIDandProcID.sql
Normal file
5
PROMS/SQL Data Tools/GetVersionIDandProcID.sql
Normal file
@ -0,0 +1,5 @@
|
||||
Select vn.versionid, vn.foldername, ItemID, Replace(Number,'\u8209?','-') ProcNum, Replace(Text,'\u8209?','-') ProcTitle from contents cc
|
||||
JOIN VEFN_GetVersionItems('') VI ON VI.ContentID = CC.ContentID
|
||||
JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
Where Type = 0
|
||||
order by VersionID, ItemID
|
43
PROMS/SQL Data Tools/GetVersionItemsIncludingDeleted.sql
Normal file
43
PROMS/SQL Data Tools/GetVersionItemsIncludingDeleted.sql
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
Select * from vefn_GetVersionItemsIncludingDeleted('')
|
||||
*/
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2013 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
Create FUNCTION [dbo].[vefn_GetVersionItemsIncludingDeleted](@DocVersionList varchar(MAX))
|
||||
RETURNS @VersionItems TABLE
|
||||
(
|
||||
VersionID int,
|
||||
ItemID int,
|
||||
ContentID int primary key
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
BEGIN
|
||||
with Itemz([VersionID], [ItemID], [ContentID]) as
|
||||
(Select DV.VersionID, [I].[ItemID], [I].[ContentID]
|
||||
FROM [Items] I
|
||||
JOIN vefn_DocVersionSplit(@DocVersionList) DV
|
||||
ON I.[ItemID] = DV.[ItemID]
|
||||
Union All
|
||||
-- Children
|
||||
select Z.VersionID, I.[ItemID], I.[ContentID]
|
||||
from Itemz Z
|
||||
join tblParts P on P.ContentID = Z.ContentID
|
||||
join tblItems I on I.ItemID = P.ItemID
|
||||
Union All
|
||||
-- Siblings
|
||||
select Z.VersionID, I.[ItemID], I.[ContentID]
|
||||
from Itemz Z
|
||||
join tblItems I on I.PreviousID = Z.ItemID
|
||||
)
|
||||
insert into @VersionItems
|
||||
select VersionID, [ItemID], [ContentID]
|
||||
from ItemZ I
|
||||
--Select * From rousages RU Where RU.ContentID in (Select ContentID from ItemZ)
|
||||
OPTION (MAXRECURSION 10000)
|
||||
END
|
||||
RETURN
|
||||
END
|
@ -0,0 +1,35 @@
|
||||
select *
|
||||
,(cellColumn * cellRow) - (qTCCount * qTRCount) DifferencesT
|
||||
,(cellColumn * cellRow) - (qVCCount * qVRCount) DifferencesV
|
||||
,(cellColumn * cellRow) - (qHCCount * qHRCount) DifferencesH
|
||||
from (
|
||||
select --Data,
|
||||
ItemID, location
|
||||
--, xmlBorders
|
||||
, cellColumn, cellRow
|
||||
--, xmlBorders.query('.') qBorders
|
||||
, xBordersT.value('@Columns','int') qTCCount
|
||||
, xBordersT.value('@Rows','int') qTRCount
|
||||
, xBordersV.value('@Columns','int') qVCCount
|
||||
, xBordersV.value('@Rows','int') qVRCount
|
||||
, xBordersH.value('@Columns','int') qHCCount
|
||||
, xBordersH.value('@Rows','int') qHRCount
|
||||
from (
|
||||
select --VN.Foldername,
|
||||
Data, ItemID, dbo.ve_GetShortPath(ItemID) Location
|
||||
, cast(xBorders.value('.','nvarchar(max)') as XML) xmlBorders
|
||||
, xColumnCount.value('.','int') cellColumn
|
||||
, xRowCount.value('.','int') cellRow
|
||||
from Grids CC
|
||||
JOIN VEFN_GetVersionItems('') VI ON VI.ContentID = CC.ContentID
|
||||
-- JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
cross apply data.nodes('//MyBorderDetailString/text()') tBorders(xBorders)
|
||||
cross apply data.nodes('//ColumnInfo/Count/text()') tColumnCount(xColumnCount)
|
||||
cross apply data.nodes('//RowInfo/Count/text()') tRowCount(xRowCount)
|
||||
--where vi.ItemID = 7358592
|
||||
)t1
|
||||
cross apply xmlBorders.nodes('//VlnBorders') tBorders1(xBordersT)
|
||||
cross apply xmlBorders.nodes('//VerticalLines') tBordersV(xBordersV)
|
||||
cross apply xmlBorders.nodes('//HorizontalLines') tBordersH(xBordersH)
|
||||
) t2
|
||||
Where cellRow > qVRCount or cellColumn > qHCCount or cellRow + 1 > qHRCount or cellColumn + 1 > qVCCount
|
@ -0,0 +1,5 @@
|
||||
select left(convert(varchar,dts,120),7) datewhen,count(*) howmany
|
||||
from contents
|
||||
where dts>'August 30 2013'
|
||||
group by left(convert(varchar,dts,120),7)
|
||||
order by left(convert(varchar,dts,120),7)
|
3
PROMS/SQL Data Tools/IP3 integrated graphic usage.sql
Normal file
3
PROMS/SQL Data Tools/IP3 integrated graphic usage.sql
Normal file
@ -0,0 +1,3 @@
|
||||
select roid,docascii from drousages dr
|
||||
join documents dd on dd.docid=dr.docid
|
||||
where roid like '0002%' -- 0002 = integrated graphics for IP3
|
2
PROMS/SQL Data Tools/ListWordDocSizesAndIds.sql
Normal file
2
PROMS/SQL Data Tools/ListWordDocSizesAndIds.sql
Normal file
@ -0,0 +1,2 @@
|
||||
select contentid, dd.DocID,len(doccontent) from documents dd
|
||||
join entries ee on ee.docid = dd. DocID order by len(DocContent) desc
|
@ -0,0 +1,7 @@
|
||||
select FF.Name, vn.foldername, dbo.ve_getShortPath(ItemID) Location
|
||||
from vefn_getversionformatitems('') vi
|
||||
join Contents CC ON CC.ContentID = VI.ContentID
|
||||
Join vefn_getversionnames() vn on vn.versionid=vi.versionid
|
||||
Join Formats FF ON FF.FormatID = VI.FormatID
|
||||
where cc.Type Between 10000 and 19999 and FF.Name != 'BGEALN'
|
||||
order by vn.foldername, dbo.ve_getShortPath(ItemID)
|
1
PROMS/SQL Data Tools/Merging data into a database.sql
Normal file
1
PROMS/SQL Data Tools/Merging data into a database.sql
Normal file
@ -0,0 +1 @@
|
||||
sp_changedbowner sa
|
6
PROMS/SQL Data Tools/PI RO Table Items 82714.sql
Normal file
6
PROMS/SQL Data Tools/PI RO Table Items 82714.sql
Normal file
@ -0,0 +1,6 @@
|
||||
--select * from gridaudits where contentid=41082
|
||||
select distinct vn.foldername,dbo.ve_getshortpathfromcontentid(ga.contentid)
|
||||
from gridaudits ga
|
||||
join vefn_getversionitems('') vi on vi.contentid=ga.contentid
|
||||
join vefn_getversionnames() vn on vn.versionid=vi.versionid
|
||||
where userid='Michelle' --contentauditid --between 141940 and 141984
|
36
PROMS/SQL Data Tools/PurgeChangeManager.sql
Normal file
36
PROMS/SQL Data Tools/PurgeChangeManager.sql
Normal file
@ -0,0 +1,36 @@
|
||||
Delete from PDFs
|
||||
Delete from Versions
|
||||
Delete from DocumentAudits
|
||||
delete from Figures where ROFSTID not in(select rofstid from Associations)
|
||||
Delete from ROFSTs where ROFSTID not in(select rofstid from Associations)
|
||||
delete from roimages where rodbid not in(select rodbid from rofsts)
|
||||
delete from documents where docid not in(select docid from entries)
|
||||
PRINT 'Phase 1'
|
||||
delete from tblAnnotations where deletestatus != 0
|
||||
delete from drousages where docid in(select docid from tbldocuments where deletestatus != 0)
|
||||
delete from tblEntries where deletestatus != 0
|
||||
delete from tblDocuments where deletestatus != 0
|
||||
delete from tblGrids where deletestatus != 0
|
||||
delete from tblImages where deletestatus != 0
|
||||
PRINT 'Phase 2'
|
||||
delete from tblROUsages where deletestatus != 0
|
||||
delete from tblTransitions where deletestatus != 0
|
||||
delete from tblParts where deletestatus != 0
|
||||
delete from tblItems where deletestatus != 0
|
||||
and ItemID Not IN (Select ItemID from Parts)
|
||||
PRINT 'Purge Contents'
|
||||
delete from tblContents where deletestatus != 0
|
||||
--and ContentID Not IN(Select ContentID from Parts)
|
||||
--and ContentID Not IN(Select ContentID from Items)
|
||||
PRINT 'Phase 3'
|
||||
delete from AnnotationAudits
|
||||
delete from ContentAudits
|
||||
delete from EntryAudits
|
||||
delete from DocumentAudits
|
||||
delete from GridAudits
|
||||
delete from ImageAudits
|
||||
PRINT 'Phase 4'
|
||||
delete from ItemAudits
|
||||
delete from PartAudits
|
||||
delete from ROUsageAudits
|
||||
delete from TransitionAudits
|
32
PROMS/SQL Data Tools/Queries to Shrink DBs/CleanUpPROMS.sql
Normal file
32
PROMS/SQL Data Tools/Queries to Shrink DBs/CleanUpPROMS.sql
Normal file
@ -0,0 +1,32 @@
|
||||
Delete from PDFs
|
||||
Delete from Versions
|
||||
Delete from DocumentAUdits
|
||||
delete from Figures where ROFSTID not in(select rofstid from Associations)
|
||||
Delete from ROFSTs where ROFSTID not in(select rofstid from Associations)
|
||||
delete from roimages where rodbid not in(select rodbid from rofsts)
|
||||
delete from documents where docid not in(select docid from entries)
|
||||
-- Phase 1
|
||||
delete from tblAnnotations where deletestatus != 0
|
||||
delete from drousages where docid in(select docid from tbldocuments where deletestatus != 0)
|
||||
delete from tblEntries where deletestatus != 0
|
||||
delete from tblDocuments where deletestatus != 0
|
||||
delete from tblGrids where deletestatus != 0
|
||||
delete from tblImages where deletestatus != 0
|
||||
--Phase 2 -
|
||||
delete from tblROUsages where deletestatus != 0
|
||||
delete from tblTransitions where deletestatus != 0
|
||||
delete from tblParts where deletestatus != 0
|
||||
delete from tblItems where deletestatus != 0
|
||||
delete from tblContents where deletestatus != 0
|
||||
--Phase 3 -
|
||||
delete from AnnotationAudits
|
||||
delete from ContentAudits
|
||||
delete from EntryAudits
|
||||
delete from DocumentAudits
|
||||
delete from GridAudits
|
||||
delete from ImageAudits
|
||||
--Phase 4 -
|
||||
delete from ItemAudits
|
||||
delete from PartAudits
|
||||
delete from ROUsageAudits
|
||||
delete from TransitionAudits
|
@ -0,0 +1,960 @@
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstHeaderInsert] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstHeaderInsert]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetRofstByID] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetRofstByID]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetDatabases] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetDatabases]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetDatabaseByID] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetDatabaseByID]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRoid] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildrenByRoid]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRofstID] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildrenByRofstID]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByRoid] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildByRoid]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByID] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildByID]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByAccPageID] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildByAccPageID]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataExists] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataExists]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDatabaseInsert] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDatabaseInsert]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstChildInsert] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstChildInsert]
|
||||
GO
|
||||
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RofstHeader]') AND type in (N'U'))
|
||||
ALTER TABLE [dbo].[RofstHeader] DROP CONSTRAINT IF EXISTS [FK_RofstHeader_ROFsts]
|
||||
GO
|
||||
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RofstDatabase]') AND type in (N'U'))
|
||||
ALTER TABLE [dbo].[RofstDatabase] DROP CONSTRAINT IF EXISTS [FK_RofstDatabase_RofstHeader]
|
||||
GO
|
||||
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RofstChild]') AND type in (N'U'))
|
||||
ALTER TABLE [dbo].[RofstChild] DROP CONSTRAINT IF EXISTS [FK_RofstChild_RofstDatabase]
|
||||
GO
|
||||
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RofstHeader]') AND type in (N'U'))
|
||||
ALTER TABLE [dbo].[RofstHeader] DROP CONSTRAINT IF EXISTS [DF_RofstHeader_CreateDate]
|
||||
GO
|
||||
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RofstHeader]') AND type in (N'U'))
|
||||
ALTER TABLE [dbo].[RofstHeader] DROP CONSTRAINT IF EXISTS [DF_RofstHeader_CreateUserID]
|
||||
GO
|
||||
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RofstDatabase]') AND type in (N'U'))
|
||||
ALTER TABLE [dbo].[RofstDatabase] DROP CONSTRAINT IF EXISTS [DF_RofstDatabase_ParentID]
|
||||
GO
|
||||
/****** Object: Index [IX_RofstID_Roid] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP INDEX IF EXISTS [IX_RofstID_Roid] ON [dbo].[RofstChild]
|
||||
GO
|
||||
/****** Object: Index [IX_RofstID_DbiID_ParentID] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP INDEX IF EXISTS [IX_RofstID_DbiID_ParentID] ON [dbo].[RofstChild]
|
||||
GO
|
||||
/****** Object: View [dbo].[vwRofstData_RofstDatabases] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstDatabases]
|
||||
GO
|
||||
/****** Object: View [dbo].[vwRofstData_RofstGroups] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstGroups]
|
||||
GO
|
||||
/****** Object: View [dbo].[vwRofstData_RofstHeaders] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstHeaders]
|
||||
GO
|
||||
/****** Object: Table [dbo].[RofstHeader] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP TABLE IF EXISTS [dbo].[RofstHeader]
|
||||
GO
|
||||
/****** Object: View [dbo].[vwRofstData_RofstChildren] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstChildren]
|
||||
GO
|
||||
/****** Object: Table [dbo].[RofstDatabase] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP TABLE IF EXISTS [dbo].[RofstDatabase]
|
||||
GO
|
||||
/****** Object: Table [dbo].[RofstChild] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP TABLE IF EXISTS [dbo].[RofstChild]
|
||||
GO
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ParseStringListToTable] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP FUNCTION IF EXISTS [dbo].[vefn_ParseStringListToTable]
|
||||
GO
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_NumOfOccurrences] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
DROP FUNCTION IF EXISTS [dbo].[vefn_NumOfOccurrences]
|
||||
GO
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_NumOfOccurrences] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
-- ==========================================================================================
|
||||
-- Author: Jake Ropar
|
||||
-- Create Date: 3/1/2022
|
||||
-- Description: Returns the number of occurences of a specific value in a specified string
|
||||
-- ==========================================================================================
|
||||
|
||||
CREATE FUNCTION [dbo].[vefn_NumOfOccurrences](@Text VarChar(Max), @Value VarChar(Max)) Returns Int
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
|
||||
Declare @ValueCount Int;
|
||||
|
||||
If (Len(@Value) = 0)
|
||||
Set @ValueCount = 0;
|
||||
Else
|
||||
Set @ValueCount = (Len(@Text) - Len(Replace(@Text, @Value, ''))) / Len(@Value);
|
||||
|
||||
Return @ValueCount;
|
||||
|
||||
END
|
||||
GO
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ParseStringListToTable] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
|
||||
-- ==========================================================================================
|
||||
-- Author: Jake Ropar
|
||||
-- Create Date: 3/26/2018
|
||||
-- Description: Splits a delimited list of strings into a table of string values
|
||||
-- ==========================================================================================
|
||||
|
||||
Create Function [dbo].[vefn_ParseStringListToTable] ( @List VarChar(Max), @Delimeter VarChar(1) = null )
|
||||
Returns @RetVal Table (ListPosition Int Identity(1,1) Not Null, ListValue VarChar(Max) Not Null)
|
||||
With Execute As Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Declare @Position Int;
|
||||
Declare @TextPosition Int;
|
||||
Declare @Length smallint;
|
||||
Declare @String VarChar(Max);
|
||||
Declare @TempString VarChar(Max);
|
||||
Declare @LeftOver VarChar(Max);
|
||||
|
||||
Set @TextPosition = 1;
|
||||
Set @LeftOver = '';
|
||||
Set @Delimeter = IsNull(@Delimeter, ',');
|
||||
|
||||
If (DataLength(@List) = 1)
|
||||
Insert @RetVal (ListValue) Values (Cast(@List as VarChar(Max)));
|
||||
Else
|
||||
Begin
|
||||
While (@TextPosition <= DataLength(@List) / 2)
|
||||
Begin
|
||||
|
||||
Set @Length = (4000 - DataLength(@LeftOver) / 2);
|
||||
Set @TempString = LTrim(@LeftOver + Substring(@List, @TextPosition, @Length));
|
||||
Set @TextPosition = @TextPosition + @Length;
|
||||
Set @Position = CharIndex(@Delimeter, @TempString);
|
||||
|
||||
While (@Position > 0)
|
||||
Begin
|
||||
|
||||
Set @String = Substring(@TempString, 1, @Position - 1);
|
||||
|
||||
Insert @RetVal (ListValue) Values (Cast(@String as VarChar(Max)));
|
||||
|
||||
Set @TempString = LTrim(Substring(@TempString, @Position + 1, Len(@TempString)));
|
||||
Set @Position = CharIndex(@Delimeter, @TempString);
|
||||
|
||||
End
|
||||
|
||||
Set @LeftOver = @TempString;
|
||||
End
|
||||
End
|
||||
|
||||
If (LTrim(RTrim(@LeftOver)) <> '')
|
||||
Insert @RetVal (ListValue) Values (Cast(@LeftOver as VarChar(Max)));
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: Table [dbo].[RofstChild] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[RofstChild](
|
||||
[RofstChildID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[RofstID] [int] NOT NULL,
|
||||
[dbiID] [int] NOT NULL,
|
||||
[ID] [int] NOT NULL,
|
||||
[ParentID] [int] NOT NULL,
|
||||
[type] [int] NOT NULL,
|
||||
[title] [varchar](max) NOT NULL,
|
||||
[roid] [varchar](50) NOT NULL,
|
||||
[appid] [varchar](max) NULL,
|
||||
[value] [varchar](max) NULL,
|
||||
CONSTRAINT [PK_RofstChild] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[RofstChildID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
/****** Object: Table [dbo].[RofstDatabase] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[RofstDatabase](
|
||||
[RofstID] [int] NOT NULL,
|
||||
[dbiID] [int] NOT NULL,
|
||||
[dbiType] [int] NOT NULL,
|
||||
[dbiAW] [int] NOT NULL,
|
||||
[dbiTitle] [varchar](max) NOT NULL,
|
||||
[dbiAP] [varchar](max) NOT NULL,
|
||||
[ID] [int] NOT NULL,
|
||||
[ParentID] [int] NOT NULL,
|
||||
CONSTRAINT [PK_RofstDatabase_1] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[RofstID] ASC,
|
||||
[dbiID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
||||
GO
|
||||
/****** Object: View [dbo].[vwRofstData_RofstChildren] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2024
|
||||
Description: (RofstData) Master View for RofstChildren (RoChild & Groups)
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create View [dbo].[vwRofstData_RofstChildren]
|
||||
As
|
||||
|
||||
Select rc.RofstChildID as 'RofstChildID',
|
||||
rd.RofstID as 'RofstID',
|
||||
rd.dbiID as 'dbiID',
|
||||
rd.dbiType as 'dbiType',
|
||||
rd.dbiAW as 'dbiAW',
|
||||
rd.dbiTitle as 'dbiTitle',
|
||||
rd.dbiAP as 'dbiAP',
|
||||
rc.ID as 'ID',
|
||||
rc.ParentID as 'ParentID',
|
||||
rc.[type] as 'type',
|
||||
rc.title as 'title',
|
||||
rc.roid as 'roid',
|
||||
rc.appid as 'appid',
|
||||
rc.[value] as 'value',
|
||||
Case When (Not rc.[value] is null) Then rd.dbiAP + '-' + rc.appid Else null End as 'AccPageID'
|
||||
From RofstChild rc With (NoLock)
|
||||
inner join RofstDatabase rd With (NoLock) on rc.RofstID = rd.RofstID and rc.dbiID = rd.dbiID;
|
||||
|
||||
|
||||
GO
|
||||
/****** Object: Table [dbo].[RofstHeader] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
CREATE TABLE [dbo].[RofstHeader](
|
||||
[RofstID] [int] NOT NULL,
|
||||
[hSize] [int] NOT NULL,
|
||||
[hMonth] [int] NOT NULL,
|
||||
[hDay] [int] NOT NULL,
|
||||
[hcYear] [int] NOT NULL,
|
||||
[hcMonth] [int] NOT NULL,
|
||||
[hcDay] [int] NOT NULL,
|
||||
[hcHour] [int] NOT NULL,
|
||||
[hcMin] [int] NOT NULL,
|
||||
[hcSec] [int] NOT NULL,
|
||||
[hcHund] [int] NOT NULL,
|
||||
[CreateUserID] [varchar](50) NOT NULL,
|
||||
[CreateDate] [datetime] NOT NULL,
|
||||
CONSTRAINT [PK_RofstHeader] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[RofstID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
/****** Object: View [dbo].[vwRofstData_RofstHeaders] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2024
|
||||
Description: (RofstData) Master View for RofstHeaders
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create View [dbo].[vwRofstData_RofstHeaders]
|
||||
As
|
||||
|
||||
Select rh.RofstID as 'RofstID',
|
||||
rh.hSize as 'hSize',
|
||||
rh.hMonth as 'hMonth',
|
||||
rh.hDay as 'hDay',
|
||||
rh.hcYear as 'hcYear',
|
||||
rh.hcMonth as 'hcMonth',
|
||||
rh.hcDay as 'hcDay',
|
||||
rh.hcHour as 'hcHour',
|
||||
rh.hcMin as 'hcMin',
|
||||
rh.hcSec as 'hcSec',
|
||||
rh.hcHund as 'hcHund',
|
||||
rh.CreateUserID as 'CreateUserID',
|
||||
rh.CreateDate as 'CreateDate'
|
||||
From RofstHeader rh With (NoLock)
|
||||
|
||||
|
||||
GO
|
||||
/****** Object: View [dbo].[vwRofstData_RofstGroups] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2024
|
||||
Description: (RofstData) Master View for RofstGroups
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create View [dbo].[vwRofstData_RofstGroups]
|
||||
As
|
||||
|
||||
Select rd.RofstID as 'RofstID',
|
||||
rd.dbiID as 'dbiID',
|
||||
rd.dbiType as 'dbiType',
|
||||
rd.dbiAW as 'dbiAW',
|
||||
rd.dbiTitle as 'dbiTitle',
|
||||
rd.dbiAP as 'dbiAP',
|
||||
rc.ID as 'ID',
|
||||
rc.ParentID as 'ParentID',
|
||||
rc.type as 'type',
|
||||
rc.title as 'title',
|
||||
rc.roid as 'riod'
|
||||
From RofstChild rc With (NoLock)
|
||||
inner join RofstDatabase rd With (NoLock) on rc.RofstID = rd.RofstID and rc.dbiID = rd.dbiID
|
||||
Where rc.value is null;
|
||||
|
||||
GO
|
||||
/****** Object: View [dbo].[vwRofstData_RofstDatabases] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2024
|
||||
Description: (RofstData) Master View for RofstDatabases
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create View [dbo].[vwRofstData_RofstDatabases]
|
||||
As
|
||||
|
||||
Select rd.RofstID as 'RofstID',
|
||||
rd.dbiID as 'dbiID',
|
||||
rd.dbiType as 'dbiType',
|
||||
rd.dbiAW as 'dbiAW',
|
||||
rd.dbiTitle as 'dbiTitle',
|
||||
rd.dbiAP as 'dbiAP',
|
||||
rd.ID as 'ID',
|
||||
rd.ParentID as 'ParentID'
|
||||
From RofstDatabase rd With (NoLock)
|
||||
|
||||
|
||||
GO
|
||||
/****** Object: Index [IX_RofstID_DbiID_ParentID] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
CREATE NONCLUSTERED INDEX [IX_RofstID_DbiID_ParentID] ON [dbo].[RofstChild]
|
||||
(
|
||||
[RofstID] ASC,
|
||||
[dbiID] ASC,
|
||||
[ParentID] ASC
|
||||
)
|
||||
INCLUDE([ID],[type],[title],[roid],[appid],[value]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
GO
|
||||
SET ANSI_PADDING ON
|
||||
GO
|
||||
/****** Object: Index [IX_RofstID_Roid] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
CREATE NONCLUSTERED INDEX [IX_RofstID_Roid] ON [dbo].[RofstChild]
|
||||
(
|
||||
[RofstID] ASC,
|
||||
[roid] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
GO
|
||||
ALTER TABLE [dbo].[RofstDatabase] ADD CONSTRAINT [DF_RofstDatabase_ParentID] DEFAULT ((0)) FOR [ParentID]
|
||||
GO
|
||||
ALTER TABLE [dbo].[RofstHeader] ADD CONSTRAINT [DF_RofstHeader_CreateUserID] DEFAULT ('SYSTEM') FOR [CreateUserID]
|
||||
GO
|
||||
ALTER TABLE [dbo].[RofstHeader] ADD CONSTRAINT [DF_RofstHeader_CreateDate] DEFAULT (getdate()) FOR [CreateDate]
|
||||
GO
|
||||
ALTER TABLE [dbo].[RofstChild] WITH CHECK ADD CONSTRAINT [FK_RofstChild_RofstDatabase] FOREIGN KEY([RofstID], [dbiID])
|
||||
REFERENCES [dbo].[RofstDatabase] ([RofstID], [dbiID])
|
||||
ON DELETE CASCADE
|
||||
GO
|
||||
ALTER TABLE [dbo].[RofstChild] CHECK CONSTRAINT [FK_RofstChild_RofstDatabase]
|
||||
GO
|
||||
ALTER TABLE [dbo].[RofstDatabase] WITH CHECK ADD CONSTRAINT [FK_RofstDatabase_RofstHeader] FOREIGN KEY([RofstID])
|
||||
REFERENCES [dbo].[RofstHeader] ([RofstID])
|
||||
ON DELETE CASCADE
|
||||
GO
|
||||
ALTER TABLE [dbo].[RofstDatabase] CHECK CONSTRAINT [FK_RofstDatabase_RofstHeader]
|
||||
GO
|
||||
ALTER TABLE [dbo].[RofstHeader] WITH CHECK ADD CONSTRAINT [FK_RofstHeader_ROFsts] FOREIGN KEY([RofstID])
|
||||
REFERENCES [dbo].[ROFsts] ([ROFstID])
|
||||
ON DELETE CASCADE
|
||||
GO
|
||||
ALTER TABLE [dbo].[RofstHeader] CHECK CONSTRAINT [FK_RofstHeader_ROFsts]
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstChildInsert] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstChildInsert]
|
||||
(
|
||||
@RofstID Int,
|
||||
@ID Int,
|
||||
@ParentID Int,
|
||||
@dbiID Int,
|
||||
@type Int,
|
||||
@title VarChar(Max),
|
||||
@roid VarChar(50),
|
||||
@appid VarChar(Max) = null,
|
||||
@value VarChar(Max) = null
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
|
||||
-- Create Rofst Child/Group Record
|
||||
Insert Into RofstChild (RofstID, ID, ParentID, dbiID, [type], title, roid, appid, [value])
|
||||
Values (@RofstID, @ID, @ParentID, @dbiID, @type, @title, @roid, @appid, @value);
|
||||
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDatabaseInsert] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDatabaseInsert]
|
||||
(
|
||||
@RofstID Int,
|
||||
@dbiID Int,
|
||||
@dbiType Int,
|
||||
@dbiAW Int,
|
||||
@dbiTitle VarChar(Max),
|
||||
@dbiAP VarChar(Max),
|
||||
@ID Int,
|
||||
@ParentID Int
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
|
||||
Insert Into RofstDatabase ( RofstID, dbiID, dbiType, dbiAW, dbiTitle, dbiAP, ID, ParentID)
|
||||
Values ( @RofstID, @dbiID, @dbiType, @dbiAW, @dbiTitle, @dbiAP, @ID, @ParentID);
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataExists] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataExists]
|
||||
(
|
||||
@RofstID int
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Select Count(1)
|
||||
From RofstHeader with (NoLock)
|
||||
Where RofstID = @RofstID;
|
||||
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByAccPageID] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataGetChildByAccPageID]
|
||||
(
|
||||
@RofstID int,
|
||||
@AccPageID VarChar(50)
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Select rc.ROFstID,
|
||||
rc.dbiID,
|
||||
rc.ID,
|
||||
rc.ParentID,
|
||||
rc.[type],
|
||||
rc.title,
|
||||
rc.roid,
|
||||
rc.appid,
|
||||
rc.[value],
|
||||
rc.AccPageID
|
||||
From vwRofstData_RofstChildren rc
|
||||
Where rc.RofstID = @RofstID
|
||||
And rc.AccPageID = @AccPageID;
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByID] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataGetChildByID]
|
||||
(
|
||||
@RofstID int,
|
||||
@DbiID int,
|
||||
@ID Int
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Select rc.RofstID,
|
||||
rc.dbiID,
|
||||
rc.ID,
|
||||
rc.ParentID,
|
||||
rc.[type],
|
||||
rc.title,
|
||||
rc.roid,
|
||||
rc.appid,
|
||||
rc.[value],
|
||||
rc.AccPageID
|
||||
From vwRofstData_RofstChildren rc
|
||||
Where rc.RofstID = @RofstID
|
||||
And rc.dbiID = @DbiID
|
||||
And rc.ID = @ID;
|
||||
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByRoid] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataGetChildByRoid]
|
||||
(
|
||||
@RofstID int,
|
||||
@Roid VarChar(50)
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Select rc.ROFstID,
|
||||
rc.dbiID,
|
||||
rc.ID,
|
||||
rc.ParentID,
|
||||
rc.[type],
|
||||
rc.title,
|
||||
rc.roid,
|
||||
rc.appid,
|
||||
rc.[value],
|
||||
rc.AccPageID
|
||||
From vwRofstData_RofstChildren rc
|
||||
Where rc.RofstID = @RofstID
|
||||
And rc.roid = @Roid;
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRofstID] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataGetChildrenByRofstID]
|
||||
(
|
||||
@RofstID int
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Select rc.RofstID,
|
||||
rc.dbiID,
|
||||
rc.ID,
|
||||
rc.ParentID,
|
||||
rc.[type],
|
||||
rc.title,
|
||||
rc.roid,
|
||||
rc.appid,
|
||||
rc.[value],
|
||||
rc.AccPageID
|
||||
From vwRofstData_RofstChildren rc
|
||||
Where rc.RofstID = @RofstID
|
||||
And Not rc.[value] is null
|
||||
Order By rc.dbiID Asc, rc.[type] Asc, rc.roid Asc;
|
||||
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRoid] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataGetChildrenByRoid]
|
||||
(
|
||||
@RofstID int,
|
||||
@Roid VarChar(50)
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
With RoParent as
|
||||
(
|
||||
Select RofstID, dbiID, ID, [type], title, roid
|
||||
From vwRofstData_RofstChildren
|
||||
Where RofstID = @RofstID And roid = @Roid
|
||||
)
|
||||
Select rc.RofstID,
|
||||
rc.dbiID,
|
||||
-- Ro Parent Info
|
||||
rp.[type] as 'ParentType',
|
||||
rp.title as 'ParentTitle',
|
||||
rp.roid as 'ParentRoid',
|
||||
-- Ro Child Info
|
||||
rc.ID,
|
||||
rc.ParentID,
|
||||
rc.[type],
|
||||
rc.title,
|
||||
rc.roid,
|
||||
rc.appid,
|
||||
rc.[value],
|
||||
rc.AccPageID
|
||||
From RoParent rp
|
||||
inner join vwRofstData_RofstChildren rc on rc.RofstID = rp.RofstID and rc.dbiID = rp.dbiID and rc.ParentID = rp.ID
|
||||
Order By rc.ID Asc;
|
||||
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetDatabaseByID] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataGetDatabaseByID]
|
||||
(
|
||||
@RofstID int,
|
||||
@dbiID int
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Select rd.RofstID,
|
||||
rd.dbiID,
|
||||
rd.dbiType,
|
||||
rd.dbiAW,
|
||||
rd.dbiTitle,
|
||||
rd.dbiAP,
|
||||
rd.ID,
|
||||
rd.ParentID
|
||||
From vwRofstData_RofstDatabases rd
|
||||
Where rd.RofstID = @RofstID
|
||||
And rd.dbiID = @dbiID;
|
||||
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetDatabases] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataGetDatabases]
|
||||
(
|
||||
@RofstID int
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Select rd.RofstID,
|
||||
rd.dbiID,
|
||||
rd.dbiType,
|
||||
rd.dbiAW,
|
||||
rd.dbiTitle,
|
||||
rd.dbiAP,
|
||||
rd.ID,
|
||||
rd.ParentID
|
||||
From vwRofstData_RofstDatabases rd
|
||||
Where rd.RofstID = @RofstID
|
||||
Order By rd.dbiID Asc;
|
||||
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetRofstByID] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataGetRofstByID]
|
||||
(
|
||||
@RofstID int,
|
||||
@IncludeRoLookup Bit
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Select r.ROFstID,
|
||||
r.RODbID,
|
||||
Case (@IncludeRoLookup) When 1 Then r.ROLookup Else null End as 'ROLookup',
|
||||
r.DTS,
|
||||
r.UserID,
|
||||
r.LastChanged
|
||||
From ROFsts r with (NoLock)
|
||||
Where r.RofstID = @RofstID;
|
||||
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
/****** Object: StoredProcedure [dbo].[vesp_RofstHeaderInsert] Script Date: 4/8/2022 9:34:03 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstHeaderInsert]
|
||||
(
|
||||
@RofstID Int,
|
||||
@hSize Int,
|
||||
@hMonth Int,
|
||||
@hDay Int,
|
||||
@hcYear Int,
|
||||
@hcMonth Int,
|
||||
@hcDay Int,
|
||||
@hcHour Int,
|
||||
@hcMin Int,
|
||||
@hcSec Int,
|
||||
@hcHund Int,
|
||||
@UserID VarChar(50)
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
Insert Into RofstHeader (RofstID, hSize, hMonth, hDay, hcYear, hcMonth, hcDay, hcHour, hcMin, hcSec, hcHund, CreateUserID, CreateDate)
|
||||
Values (@RofstID, @hSize, @hMonth, @hDay, @hcYear, @hcMonth, @hcDay, @hcHour, @hcMin, @hcSec, @hcHund, @UserID, GetDate());
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,233 @@
|
||||
|
||||
IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[getJustROFst]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP Procedure [dbo].[getJustROFst];
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getJustROFst] Script Date: 5/4/2022 10:37:05 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
|
||||
CREATE PROCEDURE [dbo].[getJustROFst]
|
||||
(
|
||||
@ROFstID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[ROFstID],
|
||||
[RODbID],
|
||||
[ROLookup],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
(SELECT COUNT(1) FROM [Associations] WHERE [Associations].[ROFstID]=[ROFsts].[ROFstID]) [AssociationCount],
|
||||
(SELECT COUNT(1) FROM [Figures] WHERE [Figures].[ROFstID]=[ROFsts].[ROFstID]) [FigureCount]
|
||||
FROM [ROFsts]
|
||||
WHERE [ROFstID]=@ROFstID
|
||||
RETURN
|
||||
GO
|
||||
|
||||
|
||||
|
||||
|
||||
IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[getROFst]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP Procedure [dbo].[getROFst];
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getROFst] Script Date: 5/4/2022 10:37:49 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
|
||||
CREATE PROCEDURE [dbo].[getROFst]
|
||||
|
||||
(
|
||||
@ROFstID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[ROFstID],
|
||||
[RODbID],
|
||||
[ROLookup],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
(SELECT COUNT(1) FROM [Associations] WHERE [Associations].[ROFstID]=[ROFsts].[ROFstID]) [AssociationCount],
|
||||
(SELECT COUNT(1) FROM [Figures] WHERE [Figures].[ROFstID]=[ROFsts].[ROFstID]) [FigureCount]
|
||||
FROM [ROFsts]
|
||||
WHERE [ROFstID]=@ROFstID
|
||||
|
||||
SELECT
|
||||
[Associations].[AssociationID],
|
||||
[Associations].[VersionID],
|
||||
[Associations].[ROFstID],
|
||||
[Associations].[Config],
|
||||
[Associations].[DTS],
|
||||
[Associations].[UserID],
|
||||
[Associations].[LastChanged],
|
||||
[DocVersions].[FolderID] [DocVersion_FolderID],
|
||||
[DocVersions].[VersionType] [DocVersion_VersionType],
|
||||
[DocVersions].[Name] [DocVersion_Name],
|
||||
[DocVersions].[Title] [DocVersion_Title],
|
||||
[DocVersions].[ItemID] [DocVersion_ItemID],
|
||||
[DocVersions].[FormatID] [DocVersion_FormatID],
|
||||
[DocVersions].[Config] [DocVersion_Config],
|
||||
[DocVersions].[DTS] [DocVersion_DTS],
|
||||
[DocVersions].[UserID] [DocVersion_UserID]
|
||||
FROM [Associations]
|
||||
JOIN [DocVersions] ON
|
||||
[DocVersions].[VersionID]=[Associations].[VersionID]
|
||||
WHERE
|
||||
[Associations].[ROFstID]=@ROFstID
|
||||
|
||||
|
||||
SELECT
|
||||
[Figures].[FigureID],
|
||||
[Figures].[ROFstID],
|
||||
[Figures].[ImageID],
|
||||
[Figures].[Config],
|
||||
[Figures].[DTS],
|
||||
[Figures].[UserID],
|
||||
[Figures].[LastChanged],
|
||||
[ROImages].[RODbID] [ROImage_RODbID],
|
||||
[ROImages].[FileName] [ROImage_FileName],
|
||||
[ROImages].[Content] [ROImage_Content],
|
||||
[ROImages].[Config] [ROImage_Config],
|
||||
[ROImages].[DTS] [ROImage_DTS],
|
||||
[ROImages].[UserID] [ROImage_UserID]
|
||||
FROM [Figures]
|
||||
JOIN [ROImages] ON
|
||||
[ROImages].[ImageID]=[Figures].[ImageID]
|
||||
WHERE
|
||||
[Figures].[ROFstID]=@ROFstID
|
||||
|
||||
RETURN
|
||||
GO
|
||||
|
||||
|
||||
|
||||
|
||||
IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[getROFstByRODbID_DTS]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP Procedure [dbo].[getROFstByRODbID_DTS];
|
||||
GO
|
||||
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getROFstByRODbID_DTS] Script Date: 5/4/2022 10:46:34 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
|
||||
CREATE PROCEDURE [dbo].[getROFstByRODbID_DTS]
|
||||
(
|
||||
@RODbID int,
|
||||
@DTS datetime
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[ROFstID],
|
||||
[RODbID],
|
||||
[ROLookup],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
(SELECT COUNT(1) FROM [Associations] WHERE [Associations].[ROFstID]=[ROFsts].[ROFstID]) [AssociationCount],
|
||||
(SELECT COUNT(1) FROM [Figures] WHERE [Figures].[ROFstID]=[ROFsts].[ROFstID]) [FigureCount]
|
||||
FROM [ROFsts]
|
||||
WHERE [RODbID]=@RODbID AND [DTS]=@DTS
|
||||
|
||||
|
||||
RETURN
|
||||
GO
|
||||
|
||||
|
||||
|
||||
|
||||
IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[getROFsts]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP Procedure [dbo].[getROFsts];
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getROFsts] Script Date: 5/4/2022 10:49:07 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
|
||||
CREATE PROCEDURE [dbo].[getROFsts]
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[ROFstID],
|
||||
[RODbID],
|
||||
[ROLookup],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
(SELECT COUNT(1) FROM [Associations] WHERE [Associations].[ROFstID]=[ROFsts].[ROFstID]) [AssociationCount],
|
||||
(SELECT COUNT(1) FROM [Figures] WHERE [Figures].[ROFstID]=[ROFsts].[ROFstID]) [FigureCount]
|
||||
FROM [ROFsts]
|
||||
RETURN
|
||||
GO
|
||||
|
||||
|
||||
|
||||
|
||||
IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[getROFstsByRODbID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP Procedure [dbo].[getROFstsByRODbID];
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getROFstsByRODbID] Script Date: 5/4/2022 10:50:14 AM ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
|
||||
CREATE PROCEDURE [dbo].[getROFstsByRODbID]
|
||||
|
||||
(
|
||||
@RODbID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
|
||||
SELECT
|
||||
[ROFsts].[ROFstID],
|
||||
[ROFsts].[RODbID],
|
||||
[ROFsts].[ROLookup],
|
||||
[ROFsts].[Config],
|
||||
[ROFsts].[DTS],
|
||||
[ROFsts].[UserID],
|
||||
[ROFsts].[LastChanged],
|
||||
(SELECT COUNT(1) FROM [Associations] WHERE [Associations].[ROFstID]=[ROFsts].[ROFstID]) [AssociationCount],
|
||||
(SELECT COUNT(1) FROM [Figures] WHERE [Figures].[ROFstID]=[ROFsts].[ROFstID]) [FigureCount]
|
||||
FROM [ROFsts]
|
||||
WHERE
|
||||
[ROFsts].[RODbID]=@RODbID
|
||||
|
||||
RETURN
|
||||
GO
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,64 @@
|
||||
|
||||
IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildrenByType]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP Procedure [dbo].[vesp_RofstDataGetChildrenByType];
|
||||
GO
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2020 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
/*
|
||||
==========================================================================================================
|
||||
Author: Jake Ropar
|
||||
Create Date: 03/24/2022
|
||||
Description:
|
||||
==========================================================================================================
|
||||
*/
|
||||
Create Procedure [dbo].[vesp_RofstDataGetChildrenByType]
|
||||
(
|
||||
@RofstID int,
|
||||
@ValueTypes VarChar(Max)
|
||||
)
|
||||
With Execute as Owner
|
||||
As
|
||||
Begin
|
||||
|
||||
-- Remove any leading/trailing white spaces
|
||||
Set @ValueTypes = dbo.vefn_Clean( @ValueTypes, 0, null );
|
||||
|
||||
-- Format search value
|
||||
If (Len(@ValueTypes) = 0) Set @ValueTypes = null;
|
||||
|
||||
With ValueTypes as
|
||||
(
|
||||
Select Cast(x.ListValue as Int) as 'ListValue'
|
||||
From dbo.vefn_ParseStringListToTable(@ValueTypes, ',') as x
|
||||
)
|
||||
Select rc.ROFstID,
|
||||
rc.dbiID,
|
||||
rc.ID,
|
||||
rc.ParentID,
|
||||
rc.[type],
|
||||
rc.title,
|
||||
rc.roid,
|
||||
rc.appid,
|
||||
rc.[value],
|
||||
rc.AccPageID
|
||||
From vwRofstData_RofstChildren rc
|
||||
Left outer join ValueTypes vt on vt.ListValue = rc.[type]
|
||||
Where rc.RofstID = @RofstID
|
||||
And Not rc.[value] is null
|
||||
And (@ValueTypes is null Or Not vt.ListValue is null)
|
||||
Option (Recompile);
|
||||
|
||||
Return;
|
||||
End
|
||||
|
||||
GO
|
||||
|
||||
|
205
PROMS/SQL Data Tools/ROCleanUp.sql
Normal file
205
PROMS/SQL Data Tools/ROCleanUp.sql
Normal file
@ -0,0 +1,205 @@
|
||||
SET NOCOUNT ON
|
||||
Select RODBID, ROName, FolderPath
|
||||
, (Select Count(*) from ROUSAGES UU where UU.RODBID = DB.RODBID) Usages
|
||||
, (Select Count(*) from DROUSAGES UU where UU.RODBID = DB.RODBID) DocUsages
|
||||
, (Select Count(*) from ROFSTs FS where FS.RODBID = DB.RODBID) ROFSTs
|
||||
, (select Count(*) from Associations AA
|
||||
Join ROFSTs RF On RF.ROFstID=AA.ROFstID where RF.RODBID = DB.RODBID) Associations
|
||||
, (select Count(*) from Figures FF
|
||||
Join ROFSTs RF On RF.ROFstID=FF.ROFstID where RF.RODBID = DB.RODBID) Figures
|
||||
from RODBS DB
|
||||
GO
|
||||
EXECUTE [vesp_TurnChangeManagerOFF]
|
||||
GO
|
||||
PRINT ' 1 Purge Multiple Associations'
|
||||
begin
|
||||
with cte as (
|
||||
Select *, Row_Number() over (partition by VersionID order by associationID ) MyRank from Associations
|
||||
)
|
||||
delete CTE where MyRank > 1
|
||||
end
|
||||
|
||||
DECLARE @FstRanks as TABLE
|
||||
(
|
||||
ROFSTID int primary key,
|
||||
UniqueRow int,
|
||||
Duplicate int
|
||||
)
|
||||
PRINT ' 2 Find Duplicate ROFSTs'
|
||||
Insert into @FstRanks
|
||||
Select ROFSTID
|
||||
, DENSE_RANK() Over (order by ROLOOKUP) UniqueRow
|
||||
, ROW_NUMBER() Over (partition by ROLOOKUP order by ROLOOKUP) Duplicate
|
||||
From ROFSTs
|
||||
|
||||
DECLARE @Trans as TABLE
|
||||
(
|
||||
ROFSTID int,
|
||||
VersionID int
|
||||
)
|
||||
|
||||
PRINT ' 3 Create a Translation Table'
|
||||
|
||||
Insert Into @Trans
|
||||
Select (Select Min(ROFSTID) From @FstRanks where UniqueRow = RNK.UniqueRow) ROFSTID,
|
||||
AA.VersionID
|
||||
from ROFSTs RF
|
||||
Join @FstRanks RNK ON RF.ROFSTID = RNK.ROFSTID
|
||||
Join Associations AA on AA.RofstID = RF.ROFstID
|
||||
|
||||
PRINT ' 4 Translate RO Associations'
|
||||
|
||||
Update AA set ROFSTID = TT.ROFSTID
|
||||
From Associations AA
|
||||
Join @Trans TT ON AA.VersionID = TT.VersionID
|
||||
|
||||
|
||||
PRINT ' 5 Contents - replacing rodbid''s in content records'' link text'
|
||||
|
||||
update cc set text = replace(text, ' ' + cast(ru.rodbid as varchar(2)) + '[END>', ' 1[END>')
|
||||
from Contents CC
|
||||
Join ROUsages RU ON CC.ContentID = RU.ContentID
|
||||
where RU.rodbid !=1
|
||||
|
||||
PRINT ' 6 Grids - replacing rodbid''s in grid records'' link text'
|
||||
|
||||
update GG set data = cast(replace(cast(data as nvarchar(max)), ' ' + cast(ru.rodbid as varchar(2)) + '[END>', ' 1[END>') as xml)
|
||||
from Grids GG
|
||||
Join ROUsages RU ON GG.ContentID = RU.ContentID
|
||||
where RU.rodbid !=1
|
||||
|
||||
PRINT ' 7 Update ROUsages to use the same RODBID'
|
||||
update tblROUsages set rodbid = 1
|
||||
where rodbid != 1
|
||||
|
||||
PRINT ' 8 Update DROUsages to use the same RODBID'
|
||||
update DROUsages set rodbid = 1
|
||||
where rodbid != 1
|
||||
|
||||
DECLARE @TransImageID table
|
||||
(
|
||||
ImageID int primary key,
|
||||
TransImageID int
|
||||
)
|
||||
begin
|
||||
with cte as (
|
||||
select dense_rank() over (order by content) MyRank
|
||||
,row_number() over (partition by content order by RODBID ) Duplicate,*
|
||||
from roimages)
|
||||
Insert Into @TransImageID
|
||||
select CT1.ImageID , CT2.ImageID TransID from CTE CT1
|
||||
Join (select ImageID, MyRank From CTE where Duplicate = 1) CT2 ON CT1.MyRank = CT2.MyRank
|
||||
--Where CT1.ImageID != CT2.ImageID
|
||||
end
|
||||
--Select * from @TransImageID order by TransImageID
|
||||
|
||||
--Remove Duplicate Figures
|
||||
delete from Figures where FigureID IN(
|
||||
select FigureID from (
|
||||
Select dense_rank() over (order by ROFstID, TransImageID) MyRank
|
||||
,row_number() over (partition by ROFstID, TransImageID order by ROFstID, TransImageID ) Duplicate,FF.*, TT.TransImageID From FIgures FF
|
||||
Join @TransImageID TT ON FF.ImageID = TT.ImageID
|
||||
) T1 where Duplicate > 1)
|
||||
|
||||
--
|
||||
|
||||
/*--select * from (
|
||||
Select dense_rank() over (order by ROFstID, TransImageID) MyRank
|
||||
,row_number() over (partition by ROFstID, TransImageID order by ROFstID, TransImageID ) Duplicate,FF.*, TT.TransImageID From FIgures FF
|
||||
Join @TransImageID TT ON FF.ImageID = TT.ImageID
|
||||
--) T1 where Duplicate > 1
|
||||
*/
|
||||
|
||||
PRINT ' 9 Translate RO ImageIDs'
|
||||
|
||||
Update FF Set FF.ImageID = TT.TransImageID
|
||||
From FIgures FF
|
||||
Join @TransImageID TT ON FF.ImageID = TT.ImageID
|
||||
|
||||
PRINT '10 Remove duplicate ROImages'
|
||||
|
||||
Delete from ROImages where ImageID in (Select ImageID from @TransImageID where ImageID != TransImageID)
|
||||
|
||||
PRINT '11 Point ROImages at RODBID = 1'
|
||||
Update RoImages Set RODBID = 1 where RODBID != 1
|
||||
|
||||
PRINT '12 Add Missing Figures'
|
||||
|
||||
DECLARE @LastROFstID int
|
||||
select @LastROFstID=max(ROFstID) from ROFSTs
|
||||
DECLARE @LastFigureCount int
|
||||
select @LastFigureCount=count(*) from Figures where ROFstid = @LastROFstID
|
||||
DECLARE @LastRODBID int
|
||||
select @LastRODBID= RODBID from ROFSTs where ROFstID = @LastROFstID
|
||||
DECLARE @tbl TABLE
|
||||
(
|
||||
ROFSTID int,
|
||||
HowMany int
|
||||
)
|
||||
insert into @tbl
|
||||
select RF.ROFSTID, Count(FF.ROFSTID) HowMany from ROFSTs RF
|
||||
Join Figures FF ON FF.ROFstID=RF.ROFSTID
|
||||
Where RODBID = @LastRODBID group by RF.ROFSTID
|
||||
DECLARE @MaxFigures int
|
||||
select @MaxFigures=max(HowMany) from @Tbl
|
||||
DECLARE @RecentGoodROFSTID int
|
||||
select @RecentGoodROFSTID = Max(ROFSTID) from @tbl where HowMany = @MaxFigures
|
||||
--select * from @tbl
|
||||
--Print '
|
||||
--Latest ROFSTID ' + cast(@LastROFstID as varchar(25)) + '
|
||||
--Latest Figure Count ' + cast(@LastFigureCount as varchar(25)) + '
|
||||
--Maximum Figure Count ' + cast(@MaxFigures as varchar(25)) + '
|
||||
--Latest Good ROFSTID ' + cast(@RecentGoodROFstID as varchar(25)) + '
|
||||
--'
|
||||
|
||||
INSERT INTO [dbo].[Figures]
|
||||
([ROFstID],[ImageID],[Config],[DTS],[UserID])
|
||||
select AA.ROFstID, FF.ImageID, FF.Config ,FF.DTS,FF.UserID from (select Distinct ROFSTID from Associations) AA
|
||||
Join (select ImageID,Config,DTS,UserID from Figures Where ROFstID = @RecentGoodROFSTID) FF ON AA.ROFstID=aa.ROFstID
|
||||
Left Join Figures F2 ON AA.ROFstID = f2.ROFstID and ff.ImageID = F2.ImageID
|
||||
Where F2.FigureID is null
|
||||
|
||||
|
||||
|
||||
--begin
|
||||
--with CTE as (
|
||||
--select AA.ROFstID, FF.ImageID, FF.Config ,FF.DTS,FF.UserID from (select Distinct ROFSTID from Associations) AA
|
||||
--Join (select ImageID,Config,DTS,UserID from Figures Where ROFstID = @RecentGoodROFSTID) FF ON AA.ROFstID=aa.ROFstID
|
||||
--Left Join Figures F2 ON AA.ROFstID = f2.ROFstID and ff.ImageID = F2.ImageID
|
||||
--Where F2.FigureID is null
|
||||
--)
|
||||
--select ROFSTID, Count(*) NewFigures , (select Count(*) from Figures FF where CTE.ROFSTID = FF.ROFSTID) OldFigures from CTE Group By ROFSTID
|
||||
--end
|
||||
|
||||
|
||||
PRINT '13 Remove unused Figures'
|
||||
|
||||
Delete From Figures where ROFstID not in(Select ROFSTID from Associations)
|
||||
|
||||
PRINT '14 remove unused ROFSTs'
|
||||
|
||||
Delete From ROFSTS where ROFstID not in(Select ROFSTID from Associations)
|
||||
|
||||
PRINT '15 Point ROFSTs at RODBID=1'
|
||||
|
||||
Update ROFSTs Set RODBID = 1
|
||||
Where RODBID != 1
|
||||
|
||||
PRINT '16 Remove unused RODBs'
|
||||
|
||||
Delete RODBs Where RODBID != 1
|
||||
|
||||
PRINT '17 Rename RODB'
|
||||
Update RODBs Set ROName='RO'
|
||||
GO
|
||||
EXECUTE [vesp_TurnChangeManagerON]
|
||||
GO
|
||||
Select RODBID, ROName, FolderPath
|
||||
, (Select Count(*) from ROUSAGES UU where UU.RODBID = DB.RODBID) Usages
|
||||
, (Select Count(*) from DROUSAGES UU where UU.RODBID = DB.RODBID) DocUsages
|
||||
, (Select Count(*) from ROFSTs FS where FS.RODBID = DB.RODBID) ROFSTs
|
||||
, (select Count(*) from Associations AA
|
||||
Join ROFSTs RF On RF.ROFstID=AA.ROFstID where RF.RODBID = DB.RODBID) Associations
|
||||
, (select Count(*) from Figures FF
|
||||
Join ROFSTs RF On RF.ROFstID=FF.ROFstID where RF.RODBID = DB.RODBID) Figures
|
||||
from RODBS DB
|
1
PROMS/SQL Data Tools/RODBS.sql
Normal file
1
PROMS/SQL Data Tools/RODBS.sql
Normal file
@ -0,0 +1 @@
|
||||
select * from rodbs
|
6
PROMS/SQL Data Tools/RODatabaseUsage.sql
Normal file
6
PROMS/SQL Data Tools/RODatabaseUsage.sql
Normal file
@ -0,0 +1,6 @@
|
||||
select vn.VersionID, foldername, rf.ROFstID,rf.DTS,rf.rodbid, rd.FolderPath ,
|
||||
(select count(*) from vefn_getversionitems(cast(vn.versionid as varchar(10))) VI join ROUSages RU ON VI.ContentID = RU.ContentID) ROs
|
||||
from vefn_GetVersionNames() VN
|
||||
Join Associations AA on aa.VersionID = vn.VersionID
|
||||
Join rofsts RF on RF.ROFstID = aa.ROFstID
|
||||
Join rodbs RD on RD.RODbID = rf.RODbID
|
1
PROMS/SQL Data Tools/ROFstsSize.sql
Normal file
1
PROMS/SQL Data Tools/ROFstsSize.sql
Normal file
@ -0,0 +1 @@
|
||||
select ROFSTID,RODBID,Len(ROLOOKUP) MyLength, DTS,UserID from ROFSTS
|
81
PROMS/SQL Data Tools/ROValues.sql
Normal file
81
PROMS/SQL Data Tools/ROValues.sql
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
DECLARE @TEXT nvarchar(max)
|
||||
select @TEXT = TEXT from Contents where ContentID Like 17259
|
||||
select * from vefn_SplitROs(@TEXT)
|
||||
--\v <START]\v0 11%\v #Link:ReferencedObject:2933 0003000000940000 2[END>\v0
|
||||
|
||||
SELECT ContentID, RO.Value, RO.UsageID, 'R' + RO.ROID ROID, RO.RODBID FROM CONTENTS
|
||||
CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
|
||||
|
||||
SELECT ContentID --, RO.Value, RO.UsageID, RO.ROID
|
||||
FROM CONTENTS
|
||||
--CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
|
||||
|
||||
|
||||
SELECT ContentID, RO.Value, RO.UsageID, RO.ROID FROM CONTENTS
|
||||
CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where CONTENTID = 708
|
||||
|
||||
*/
|
||||
CREATE FUNCTION [dbo].[vefn_SplitROs](@text varchar(MAX))
|
||||
RETURNS @ROValues TABLE
|
||||
(
|
||||
Value varchar(max),
|
||||
UsageID int,
|
||||
ROID varchar(20),
|
||||
RODBID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @START nvarchar(255)
|
||||
SET @START= '\v <START]\v0 '
|
||||
DECLARE @MIDDLE nvarchar(255)
|
||||
SET @MIDDLE = '\v #Link:'
|
||||
DECLARE @MIDDLERO nvarchar(255)
|
||||
SET @MIDDLERO = '\v #Link:ReferencedObject:'
|
||||
DECLARE @END nvarchar(255)
|
||||
SET @END = '[END>\'
|
||||
DECLARE @IndexStart int
|
||||
SET @IndexStart = CHARINDEX(@START , @text)
|
||||
DECLARE @IndexEnd int
|
||||
SET @IndexEnd = CHARINDEX(@END , @text)
|
||||
WHILE (@IndexStart > 0)
|
||||
BEGIN
|
||||
DECLARE @PARTS NVARCHAR(MAX)
|
||||
DECLARE @PART1 NVARCHAR(MAX)
|
||||
DECLARE @PART2 NVARCHAR(MAX)
|
||||
DECLARE @PART3 NVARCHAR(MAX)
|
||||
SET @IndexStart = @IndexStart + len(@START) + 1
|
||||
--PRINT @IndexStart
|
||||
--PRINT @IndexEnd
|
||||
SET @PARTS = SUBSTRING(@TEXT,@IndexStart,@IndexEnd - @IndexStart)
|
||||
--PRINT @PARTS
|
||||
DECLARE @IndexMiddle int
|
||||
SET @IndexMiddle = CHARINDEX(@Middle , @PARTS)
|
||||
SET @PART1 = LEFT(@PARTS,@IndexMiddle-1)
|
||||
--PRINT @PART1
|
||||
SET @PARTS = SUBSTRING(@PARTS,@IndexMiddle, len(@PARTS))
|
||||
IF @PARTS LIKE @MIDDLERO + '%'
|
||||
BEGIN
|
||||
SET @PARTS = SUBSTRING(@PARTS,len(@MIDDLERO)+1,len(@PARTS))
|
||||
DECLARE @IndexSpace int
|
||||
SET @IndexSpace = CHARINDEX(' ',@PARTS)
|
||||
SET @PART2 = LEFT(@PARTS,@IndexSpace-1)
|
||||
--PRINT @PART2
|
||||
SET @PARTS = LTRIM(SUBSTRING(@PARTS,@IndexSpace+1,len(@PARTS)))
|
||||
SET @IndexSpace = CHARINDEX(' ',@PARTS)
|
||||
SET @PART3 = LEFT(@PARTS,@IndexSpace-1)
|
||||
--PRINT @PART3
|
||||
SET @PARTS = LTRIM(SUBSTRING(@PARTS,@IndexSpace+1,len(@PARTS)))
|
||||
--PRINT @PARTS
|
||||
Insert INTO @ROValues Values(@PART1, CAST(@PART2 AS INT), @PART3, Cast(@Parts as int))
|
||||
END
|
||||
SET @TEXT = SUBSTRING(@TEXT,@IndexEnd + LEN(@End), LEN(@TEXT))
|
||||
SET @IndexStart = CHARINDEX(@START , @text)
|
||||
SET @IndexEnd = CHARINDEX(@END , @text)
|
||||
END
|
||||
RETURN
|
||||
END
|
7
PROMS/SQL Data Tools/RemoveFolder.sql
Normal file
7
PROMS/SQL Data Tools/RemoveFolder.sql
Normal file
@ -0,0 +1,7 @@
|
||||
--Select dv.FolderID, vn.* from vefn_GetVersionNames () vn join DocVersions dv on vn.versionid = dv.VersionID
|
||||
|
||||
declare @FolderID int
|
||||
set @FolderID = 58 -- Replace with folderid to be removed
|
||||
Delete From Associations where VersionID in (select versionid from DocVersions where folderid = @FolderID)
|
||||
Delete From DocVersions where VersionID in (select versionid from DocVersions where folderid= @FolderID)
|
||||
delete from Folders where folderid=@FolderID
|
6
PROMS/SQL Data Tools/RemoveParentFolder.sql
Normal file
6
PROMS/SQL Data Tools/RemoveParentFolder.sql
Normal file
@ -0,0 +1,6 @@
|
||||
declare @ParentFolderID int
|
||||
set @ParentFolderID =81
|
||||
Delete From Associations where VersionID in(select versionid from DocVersions where folderid in (select folderid from Folders where ParentID = @ParentFolderID))
|
||||
Delete From DocVersions where VersionID in(select versionid from DocVersions where folderid in (select folderid from Folders where ParentID = @ParentFolderID))
|
||||
delete From Folders where ParentID=@ParentFolderID
|
||||
delete from Folders where folderid=@ParentFolderID
|
15
PROMS/SQL Data Tools/RemoveUneditableStepText.sql
Normal file
15
PROMS/SQL Data Tools/RemoveUneditableStepText.sql
Normal file
@ -0,0 +1,15 @@
|
||||
select 'exec DeleteItemAndChildren ' + cast(xx.itemID as varchar(10)) + ',''RICH'''
|
||||
from (
|
||||
select ItemID from Parts
|
||||
where FromType = 6 and ContentID IN(select pp.contentid
|
||||
--,xSubSection.value('@Edit','varchar(1)') Editable
|
||||
from parts pp
|
||||
join (select Contentid, cast(config as xml) xConfig from contents) CC ON CC.ContentID= pp.ContentID
|
||||
outer apply xConfig.nodes('//SubSection') tSubSection(xSubSection)
|
||||
where fromtype in (2,6)
|
||||
and isnull(xSubSection.value('@Edit','varchar(1)'),'N')='N'
|
||||
group by pp.contentid
|
||||
having count(*) > 1) ) ah
|
||||
Cross Apply vefn_SiblingItems(ah.ItemID,null) XX
|
||||
Join Contents CC ON CC.ContentID=XX.ContentID
|
||||
order by xx.ItemID
|
@ -0,0 +1,2 @@
|
||||
update grids set data = cast(replace(cast(data as nvarchar(max)),'{\f1\fnil\fcharset0 Courier New;}','{\f1\fnil\fcharset0 FreeMono;}') as xml)
|
||||
where cast(data as nvarchar(max)) like '%{\f1\fnil\fcharset0 Courier New;}%'
|
@ -0,0 +1,3 @@
|
||||
select cc.* from contents cc
|
||||
join items ii on ii.contentid=cc.contentid
|
||||
where ii.itemid in (select itemid from parts where fromtype=5)
|
31
PROMS/SQL Data Tools/SectionFormats.sql
Normal file
31
PROMS/SQL Data Tools/SectionFormats.sql
Normal file
@ -0,0 +1,31 @@
|
||||
select versionid, folder, parent, grandparent, T1.formatid, Format, type, HowMany,
|
||||
[SectionFormatName],[IsStepSection]
|
||||
--,TopMargin,PageLength,FooterLength,LeftMargin,PageWidth
|
||||
from
|
||||
(select vv.versionid, ff.name folder, pf.name parent, gf.name grandparent, vv.formatid, fm.name Format, cc.type,
|
||||
cc.type - 10000 Ind, count(*) HowMany
|
||||
from vefn_GetVersionFormatItems('') vv
|
||||
Join contents cc on cc.ContentID = vv.contentID
|
||||
join docversions dv on vv.versionid = dv.versionid
|
||||
Join folders ff on ff.FolderID = DV.FolderID
|
||||
Join folders pf on pf.FolderID = ff.parentID
|
||||
Join folders gf on gf.FolderID = pf.parentid
|
||||
join formats fm on fm.formatid = vv.formatid
|
||||
where cc.type between 10000 and 19999
|
||||
group by vv.versionid, ff.name, pf.name, gf.name, vv.formatid, fm.name, cc.type) T1
|
||||
Join (select FormatID, v.query('..') DocStyle
|
||||
,10000 + v.value('../@Index', 'int') [SectionType]
|
||||
,[Name] [FormatName]
|
||||
,v.value('../@Name', 'varchar(255)') [SectionFormatName]
|
||||
,v.value('../@IsStepSection', 'varchar(255)') [IsStepSection]
|
||||
--,v.value('@TopMargin', 'real') TopMargin
|
||||
--,v.value('@PageLength', 'real') PageLength
|
||||
--,v.value('@FooterLength', 'real') FooterLength
|
||||
--,v.value('@LeftMargin', 'real') LeftMargin
|
||||
--,v.value('@PageWidth', 'real') PageWidth
|
||||
from Formats
|
||||
Cross APPLY Data.nodes('//DocStyle/Layout') TempXML(v)
|
||||
where FormatID In (select distinct formatid from vefn_GetVersionFormatItems('')))
|
||||
FF on FF.FormatID = T1.FormatID and ff.SectionType = T1.Type
|
||||
--Where IsStepSection = 'FALSE' and PageLength < PageWidth
|
||||
Order by sectionformatname
|
163
PROMS/SQL Data Tools/SectionStartStatus.sql
Normal file
163
PROMS/SQL Data Tools/SectionStartStatus.sql
Normal file
@ -0,0 +1,163 @@
|
||||
Declare @TopSections Table
|
||||
(
|
||||
VersionID int,
|
||||
ProcID int,
|
||||
ItemID int Primary Key,
|
||||
ContentID int,
|
||||
Level int,
|
||||
FormatID int,
|
||||
Type int
|
||||
);
|
||||
with Itemz([VersionID], ProcID, [ItemID], [ContentID], [Level]) as
|
||||
(Select DV.VersionID, DV.ItemID ProcID, [I].[ItemID], [I].[ContentID], 0
|
||||
FROM [Items] I
|
||||
JOIN vefn_DocVersionSplit('') DV ON I.[ItemID] = DV.[ItemID]
|
||||
Union All
|
||||
-- Children
|
||||
select Z.VersionID, Z.ProcID, I.[ItemID], I.[ContentID], Z.Level+1
|
||||
from Itemz Z
|
||||
join Parts P on P.ContentID = Z.ContentID
|
||||
join Items I on I.ItemID = P.ItemID
|
||||
join Contents C ON I.ContentID = C.contentID
|
||||
Where Type < 20000
|
||||
Union All
|
||||
-- Siblings
|
||||
select Z.VersionID, case when z.ProcID = z.ItemID then I.ItemID else Z.ProcID end ProcID, I.[ItemID], I.[ContentID], Z.Level
|
||||
from Itemz Z
|
||||
join Items I on I.PreviousID = Z.ItemID
|
||||
)
|
||||
insert into @TopSections
|
||||
select ZZ.VersionID, ZZ.ProcID, ZZ.[ItemID], ZZ.[ContentID], ZZ.[Level], VI.[FormatID], CC.Type
|
||||
from ItemZ ZZ
|
||||
Join vefn_GetVersionFormatItems('') VI ON ZZ.ItemID=VI.ItemID
|
||||
Join Contents CC ON ZZ.ContentID=CC.ContentID
|
||||
Where Level > 0
|
||||
OPTION (MAXRECURSION 10000)
|
||||
|
||||
DECLARE @Procedures TABLE (
|
||||
VersionID int,
|
||||
ProcID int primary key,
|
||||
PContentID int ,
|
||||
SectionStart int
|
||||
)
|
||||
Insert into @Procedures
|
||||
Select VersionID, ItemId, ContentID, xProcedure.value('@SectionStart','int') SectionStart From
|
||||
(Select VI.VersionID,VI.ItemID,VI.ContentID,Cast(Config as xml) xConfig
|
||||
from VEFN_GetVersionItems('') VI
|
||||
Join Contents CC ON CC.ContentID = VI.ContentID
|
||||
where type = 0) T1
|
||||
outer apply xConfig.nodes('//Procedure') tProcedure(xProcedure)
|
||||
|
||||
DECLARE @SectionFormats TABLE
|
||||
(
|
||||
FormatID int,
|
||||
Name nvarchar(50),
|
||||
Description nvarchar(255),
|
||||
Type int,
|
||||
IsStepSection nvarchar(10),
|
||||
SectionFormat nvarchar(255),
|
||||
NumberingSequence int
|
||||
)
|
||||
Insert Into @SectionFormats
|
||||
Select FormatID, Name, Description
|
||||
,xDocStyle.value('@Index','int')+10000 Type
|
||||
,xDocStyle.value('@IsStepSection','nvarchar(10)') IsStepSection
|
||||
,xDocStyle.value('@Name','nvarchar(255)') SectionFormat
|
||||
,xDocStyle.value('@NumberingSequence','int') NumberingSequence
|
||||
from Formats
|
||||
outer apply data.nodes('//DocStyle') tDocStyle(xDocStyle)
|
||||
where FormatID in(Select formatid from @TopSections)
|
||||
|
||||
DECLARE @OriginalSteps Table
|
||||
(
|
||||
VersionID int,
|
||||
ProcID int,
|
||||
ItemID int,
|
||||
ContentID int,
|
||||
Level int,
|
||||
FormatID int,
|
||||
Type int
|
||||
-- ,OriginalSteps char(1)
|
||||
)
|
||||
Insert Into @OriginalSteps
|
||||
Select VersionID, ProcID, ItemID, ContentID, Level, FormatID,Type
|
||||
--,isnull(xSection.value('@OriginalSteps','char(1)'),'N') OriginalSteps
|
||||
From
|
||||
(Select TS.*, cast(config as xml) xConfig From @TopSections TS
|
||||
Join Contents CC ON TS.ContentID=CC.ContentID) T1
|
||||
Outer apply xConfig.nodes('//Section') tSection(xSection)
|
||||
where isnull(xSection.value('@OriginalSteps','char(1)'),'N') ='Y'
|
||||
|
||||
--Select * from @OriginalSteps
|
||||
Declare @MultipleOriginalSteps TABLE
|
||||
(
|
||||
ProcID int primary Key,
|
||||
HowMany int
|
||||
)
|
||||
insert into @MultipleOriginalSteps
|
||||
select ProcID, Count(*) Howmany from @OriginalSteps Group by ProcID Having count(*) > 1
|
||||
|
||||
|
||||
select SectionStartStatus, OriginalStepStatus, min(procid) minprocid, Count(*) Howmany from (
|
||||
Select PP.*, dbo.ve_getShortPath(SectionStart) PathToSectionStart, SSTS.ItemID, SSTS.FormatID, SSSF.IsStepSection, SSTS.Level
|
||||
, isnull(OSExact.ItemID,OS.ItemID) OSItemID, MOS.ProcID MProcId,ossf.IsStepSection OSIsStepSection
|
||||
,case when PP.SectionStart is null THEN 'None'
|
||||
When SSTS.ItemID is null THEN 'NotSection'
|
||||
When SSTS.ProcID != PP.ProcID then 'NotInProc'
|
||||
When SSTS.Level > 1 then 'NotTopLevel'
|
||||
When SSSF.IsStepSection = 'false' then 'NotStepSection'
|
||||
When OSExact.ProcID is null THEN 'Different'
|
||||
else 'Exact' end SectionStartStatus
|
||||
,case when isnull(OSExact.ItemID,OS.ItemID) is null then 'None'
|
||||
when MOS.ProcID is not null THEN 'MultipleOS'
|
||||
When OSSF.IsStepSection = 'false' then 'NotStepSection'
|
||||
When OSExact.ProcID is null THEN 'Different'
|
||||
else 'Exact' end OriginalStepStatus
|
||||
from @Procedures PP
|
||||
Left Join @TopSections SSTS ON PP.SectionStart = SSTS.ItemID
|
||||
Left Join @SectionFormats SSSF ON SSTS.FormatID= SSSF.FormatID and SSTS.Type=SSSF.Type
|
||||
Left Join @MultipleOriginalSteps MOS ON pp.ProcID = MOS.ProcID
|
||||
Left Join @OriginalSteps OSExact ON OSExact.ProcID=pp.ProcID and OSExact.ItemID=pp.SectionStart
|
||||
Left Join (select * from @OriginalSteps Where ProcID Not In (Select Procid from @MultipleOriginalSteps)) OS ON OS.ProcID = pp.procid
|
||||
Left Join @SectionFormats OSSF ON isnull(OSExact.FormatID,OS.FormatID)= OSSF.FormatID and isnull(OSExact.Type,OS.Type)=OSSF.Type
|
||||
) T1 Group by SectionStartStatus, OriginalStepStatus
|
||||
|
||||
|
||||
Select PP.*, dbo.ve_getShortPath(SectionStart) PathToSectionStart, SSTS.ItemID, SSTS.FormatID, SSSF.IsStepSection, SSTS.Level
|
||||
, isnull(OSExact.ItemID,OS.ItemID) OSItemID, MOS.ProcID MProcId,ossf.IsStepSection OSIsStepSection
|
||||
,case when PP.SectionStart is null THEN 'None'
|
||||
When SSTS.ItemID is null THEN 'NotSection'
|
||||
When SSTS.ProcID != PP.ProcID then 'NotInProc'
|
||||
When SSTS.Level > 1 then 'NotTopLevel'
|
||||
When SSSF.IsStepSection = 'false' then 'NotStepSection'
|
||||
When OSExact.ProcID is null THEN 'Different'
|
||||
else 'Exact' end SectionStartStatus
|
||||
,case when isnull(OSExact.ItemID,OS.ItemID) is null then 'None'
|
||||
when MOS.ProcID is not null THEN 'MultipleOS'
|
||||
When OSSF.IsStepSection = 'false' then 'NotStepSection'
|
||||
When OSExact.ProcID is null THEN 'Different'
|
||||
else 'Exact' end OriginalStepStatus
|
||||
from @Procedures PP
|
||||
Left Join @TopSections SSTS ON PP.SectionStart = SSTS.ItemID
|
||||
Left Join @SectionFormats SSSF ON SSTS.FormatID= SSSF.FormatID and SSTS.Type=SSSF.Type
|
||||
Left Join @MultipleOriginalSteps MOS ON pp.ProcID = MOS.ProcID
|
||||
Left Join @OriginalSteps OSExact ON OSExact.ProcID=pp.ProcID and OSExact.ItemID=pp.SectionStart
|
||||
Left Join (select * from @OriginalSteps Where ProcID Not In (Select Procid from @MultipleOriginalSteps)) OS ON OS.ProcID = pp.procid
|
||||
Left Join @SectionFormats OSSF ON isnull(OSExact.FormatID,OS.FormatID)= OSSF.FormatID and isnull(OSExact.Type,OS.Type)=OSSF.Type
|
||||
|
||||
|
||||
/*
|
||||
Select VersionID,GrandParentName,ParentName,FolderName,[Good],[None],[NotInProc],[NotSection],[NotTopLevel]
|
||||
FROM (Select VN.*, PP.ProcID
|
||||
,case when PP.SectionStart is null THEN 'None'
|
||||
When TS.ItemID is null THEN 'NotSection'
|
||||
When TS.ProcID != PP.ProcID then 'NotInProc'
|
||||
When Level > 1 then 'NotTopLevel'
|
||||
else 'Good' end SectionStartStatus
|
||||
from @Procedures PP
|
||||
Left Join @TopSections TS ON PP.SectionStart = TS.ItemID
|
||||
Join VEFN_GetVersionNames() VN ON VN.VersionID = PP.VersionID) P1
|
||||
PIVOT(COUNT(ProcID) FOR SectionStartStatus IN ( [Good],[None],[NotInProc],[NotSection],[NotTopLevel]))
|
||||
AS P2
|
||||
Order By VersionID
|
||||
*/
|
10
PROMS/SQL Data Tools/SectionStartStatusForGivenProcID.sql
Normal file
10
PROMS/SQL Data Tools/SectionStartStatusForGivenProcID.sql
Normal file
@ -0,0 +1,10 @@
|
||||
select Type,ItemID,Number,Text, xSection.query('.') qSection
|
||||
, xProcedure.value('@SectionStart','int') SectionStart
|
||||
,isnull(xSection.value('@OriginalSteps','char(1)'),'N') OriginalSteps
|
||||
from (select *, cast(config as xml) xConfig from Contents where Type < 20000) CC
|
||||
JOIN VEFN_GetVersionProcedureItems('') VI ON VI.ContentID = CC.ContentID
|
||||
JOIN VEFN_GetVersionNames() VN ON VI.VersionID = VN.VersionID
|
||||
Outer apply xConfig.nodes('//Section') tSection(xSection)
|
||||
outer apply xConfig.nodes('//Procedure') tProcedure(xProcedure)
|
||||
Where ProcID = 21883
|
||||
Order by ItemID
|
2
PROMS/SQL Data Tools/SetDTS.sql
Normal file
2
PROMS/SQL Data Tools/SetDTS.sql
Normal file
@ -0,0 +1,2 @@
|
||||
Update Items Set DTS = cast('12/30/2016' as datetime)
|
||||
where ContentID in(select ContentID from Contents where Type = 0)
|
4
PROMS/SQL Data Tools/SetSectionsToPrintWithBorders.sql
Normal file
4
PROMS/SQL Data Tools/SetSectionsToPrintWithBorders.sql
Normal file
@ -0,0 +1,4 @@
|
||||
Update CC Set Type = 20008-type from Contents CC
|
||||
JOIN VEFN_GetVersionFormatItems('') VI ON VI.ContentID = CC.ContentID
|
||||
JOIN Formats FF ON FF.FormatID = VI.FormatID
|
||||
where type IN (10000,10001) and FF.Name='VCB1'
|
@ -0,0 +1,4 @@
|
||||
select * from RODBS
|
||||
update rodbs set folderpath='\\scana\shares\repo\apps\VCS\TEST\nsappsTest\PROMS\Devl\Unit2_3' where rodbid=2
|
||||
--set the path to where the customer keeps their ro folder
|
||||
select * from RODBS
|
@ -0,0 +1,6 @@
|
||||
select * from RODBS
|
||||
update rodbs set folderpath='K:\VE-PromsData\ro' where rodbid = 1
|
||||
--set the path to where the customer keeps their ro folder
|
||||
select * from RODBS
|
||||
|
||||
Select * from ROFSTS
|
@ -0,0 +1,4 @@
|
||||
select * from RODBS
|
||||
update rodbs set folderpath='\\a1kansas0104\PROMS\RO'
|
||||
--set the path to where the customer keeps their ro folder
|
||||
select * from RODBS
|
1
PROMS/SQL Data Tools/TurnChangeManagerON.sql
Normal file
1
PROMS/SQL Data Tools/TurnChangeManagerON.sql
Normal file
@ -0,0 +1 @@
|
||||
vesp_TurnChangeManagerON
|
1
PROMS/SQL Data Tools/VerifyROFigureCount.sql
Normal file
1
PROMS/SQL Data Tools/VerifyROFigureCount.sql
Normal file
@ -0,0 +1 @@
|
||||
select ROFSTID, DTS, (Select Count( *) from Figures ff where ff.rofstid = ru.rofstid) ImageFiles from ROfsts ru
|
7
PROMS/SQL Data Tools/VersionAssocaitions.sql
Normal file
7
PROMS/SQL Data Tools/VersionAssocaitions.sql
Normal file
@ -0,0 +1,7 @@
|
||||
SELECT DV.VersionID, FF.NAme, ASSOCIATIONID, AA.ROFSTID, RODBID
|
||||
from DocVersions DV
|
||||
JOIN Folders FF ON FF.FolderID = DV.FolderID
|
||||
JOIN Associations AA ON DV.VersionID = AA.VersionID
|
||||
JOIN ROFSTS RF ON RF.ROFSTID = AA.ROFSTID
|
||||
|
||||
-- Update Associations set ROFSTID = 4 where AssociationID = 3
|
18
PROMS/SQL Data Tools/VersionRODBIDsDetail.sql
Normal file
18
PROMS/SQL Data Tools/VersionRODBIDsDetail.sql
Normal file
@ -0,0 +1,18 @@
|
||||
SELECT VI.VersionID,
|
||||
FF.Name, RF.RODBID VersionDBID
|
||||
, .dbo.ve_GetShortPathFromContentID(CC.ContentID) Location
|
||||
, CC.ContentID, RO.Value, RO.UsageID, 'R' + RO.ROID ROID
|
||||
, RO.RODBID TextRODBID, RD.RONAME
|
||||
--, Count(*) HowMany
|
||||
FROM CONTENTS CC
|
||||
JOIN vefn_GetVersionItems('') VI ON VI.ContentID = CC.ContentID
|
||||
JOIN DocVersions DV ON DV.VersionID = VI.VersionID
|
||||
JOIN Folders FF ON FF.FolderID = DV.FolderID
|
||||
JOIN Associations AA ON DV.VersionID = AA.VersionID
|
||||
JOIN ROFSTS RF ON RF.ROFSTID = AA.ROFSTID
|
||||
JOIN RODBS RD ON RD.RODBID = RF.RODBID
|
||||
CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
|
||||
--Group By
|
||||
--VI.VersionID,
|
||||
--FF.Name, RF.RODBID , RO.RODBID, RD.ROName
|
18
PROMS/SQL Data Tools/VersionRODBIDsSummary.sql
Normal file
18
PROMS/SQL Data Tools/VersionRODBIDsSummary.sql
Normal file
@ -0,0 +1,18 @@
|
||||
SELECT --VI.VersionID,
|
||||
FF.Name, RF.RODBID VersionDBID
|
||||
--, .dbo.ve_GetShortPathFromContentID(CC.ContentID) Location
|
||||
--, CC.ContentID, RO.Value, RO.UsageID, 'R' + RO.ROID ROID
|
||||
, RO.RODBID TextRODBID, RD.RONAME
|
||||
, Count(*) HowMany
|
||||
FROM CONTENTS CC
|
||||
JOIN vefn_GetVersionItems('') VI ON VI.ContentID = CC.ContentID
|
||||
JOIN DocVersions DV ON DV.VersionID = VI.VersionID
|
||||
JOIN Folders FF ON FF.FolderID = DV.FolderID
|
||||
JOIN Associations AA ON DV.VersionID = AA.VersionID
|
||||
JOIN ROFSTS RF ON RF.ROFSTID = AA.ROFSTID
|
||||
JOIN RODBS RD ON RD.RODBID = RF.RODBID
|
||||
CROSS APPLY vefn_SplitROs(TEXT) RO
|
||||
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
|
||||
Group By
|
||||
--VI.VersionID,
|
||||
FF.Name, RF.RODBID , RO.RODBID, RD.ROName
|
53
PROMS/SQL Data Tools/WEC2VCB_01_RemoveCoverSheets.sql
Normal file
53
PROMS/SQL Data Tools/WEC2VCB_01_RemoveCoverSheets.sql
Normal file
@ -0,0 +1,53 @@
|
||||
declare @Formats TABLE
|
||||
(
|
||||
FormatID int,
|
||||
Name nvarchar(50),
|
||||
Description nvarchar(255),
|
||||
StyleType int,
|
||||
DocStyle nvarchar(255)
|
||||
)
|
||||
insert into @Formats
|
||||
select FormatID,Name,Description, 10000 + xDocStyle.value('@Index', 'int') StyleType,
|
||||
xDocStyle.value('@Name', 'nvarchar(255)') DocStyle from Formats
|
||||
cross apply data.nodes('//DocStyle') tDocStyle(xDocStyle)
|
||||
Where xDocStyle.value('@Name', 'nvarchar(255)') like 'Document Cover%' and name like 'Wst%'
|
||||
|
||||
declare @DocCoverSheets Table
|
||||
(
|
||||
ItemID int primary Key,
|
||||
ContentID int,
|
||||
PreviousID int,
|
||||
NextID int,
|
||||
PartContentID int
|
||||
)
|
||||
insert into @DocCoverSheets
|
||||
select VI.ItemID, VI.ContentID, ii.PreviousID, ip.ItemID, pp.ContentID from Contents CC
|
||||
JOIN VEFN_GetVersionFormatItems('') VI ON VI.ContentID = CC.ContentID
|
||||
JOIN VEFN_GETVERSIONNAMES() VN ON VI.VERSIONID = VN.VERSIONID
|
||||
Join @Formats FF ON FF.FormatID = VI.FormatID and CC.Type = FF.StyleType
|
||||
Join Items II ON VI.ItemID = II.ItemID
|
||||
Left Join Parts PP on PP.ItemID = VI.ItemID
|
||||
Left Join Items IP on IP.PreviousID = VI.ItemID
|
||||
Where CC.Type Between 10000 and 19999
|
||||
|
||||
select * from @docCoverSheets
|
||||
|
||||
Update TR Set TR.ToID = TT.NextID, TR.RangeID = TT.NextID
|
||||
From Transitions TR
|
||||
Join @DocCoverSheets TT ON TT.ItemID = TR.TOID
|
||||
|
||||
|
||||
-- Update Items for NextID
|
||||
|
||||
Update II Set PreviousID = TT.PreviousID
|
||||
from Items II Join @DocCoverSheets TT ON II.ItemID = TT.NextID
|
||||
|
||||
-- Update Parts for PartContentID and ItemID
|
||||
|
||||
Update PP Set ItemID = TT.NextID
|
||||
from Parts PP Join @DocCoverSheets TT ON TT.ItemID = PP.ItemID and TT.PartContentID = pp.ContentID
|
||||
|
||||
--Delete Doc Cover Sheet Items
|
||||
|
||||
Delete From tblItems where ItemID in (select ItemID from @DocCoverSheets)
|
||||
|
@ -0,0 +1 @@
|
||||
vesp_getFormatFieldsbysteptype inmenu
|
13
PROMS/SQL Data Tools/WideTables.sql
Normal file
13
PROMS/SQL Data Tools/WideTables.sql
Normal file
@ -0,0 +1,13 @@
|
||||
select Contentid, Sum(Width)/72 WidthInches from (
|
||||
select contentid
|
||||
,xWidth.value('.','int') Width
|
||||
,xRows.value('.','int') Rows
|
||||
,xColumns.value('.','int') Columns
|
||||
from grids gg
|
||||
cross apply data.nodes('//Width') tWidth(xWidth)
|
||||
cross apply data.nodes('//ColumnInfo/Count') tColumns(xColumns)
|
||||
cross apply data.nodes('//RowInfo/Count') tRows(xRows)
|
||||
--where contentid = 44566
|
||||
) AH
|
||||
where Rows=1 and Columns = 1 and Width > 500
|
||||
group by ContentID order by sum(width) desc
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user