diff --git a/PROMS/SQL Data Tools/AllDatabases_FindROsInMergedTableCells.sql b/PROMS/SQL Data Tools/AllDatabases_FindROsInMergedTableCells.sql new file mode 100644 index 00000000..b649b4e9 --- /dev/null +++ b/PROMS/SQL Data Tools/AllDatabases_FindROsInMergedTableCells.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/AnnotationsTypeYearCount.sql b/PROMS/SQL Data Tools/AnnotationsTypeYearCount.sql new file mode 100644 index 00000000..cb94c9d7 --- /dev/null +++ b/PROMS/SQL Data Tools/AnnotationsTypeYearCount.sql @@ -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) \ No newline at end of file diff --git a/PROMS/SQL Data Tools/AutomaticallyChangingOneTypeToAnother_UsedForGinnaNotesAndCautions.sql b/PROMS/SQL Data Tools/AutomaticallyChangingOneTypeToAnother_UsedForGinnaNotesAndCautions.sql new file mode 100644 index 00000000..5f3e66f8 --- /dev/null +++ b/PROMS/SQL Data Tools/AutomaticallyChangingOneTypeToAnother_UsedForGinnaNotesAndCautions.sql @@ -0,0 +1 @@ +Update contents set type=goodnumber where type=badnumber \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Barakah/Unit Info tokens in EOPs.sql b/PROMS/SQL Data Tools/Barakah/Unit Info tokens in EOPs.sql new file mode 100644 index 00000000..793d77d8 --- /dev/null +++ b/PROMS/SQL Data Tools/Barakah/Unit Info tokens in EOPs.sql @@ -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%' + diff --git a/PROMS/SQL Data Tools/Bold no more/Bold no more.sql b/PROMS/SQL Data Tools/Bold no more/Bold no more.sql new file mode 100644 index 00000000..35a0a117 --- /dev/null +++ b/PROMS/SQL Data Tools/Bold no more/Bold no more.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Bold no more/README.txt b/PROMS/SQL Data Tools/Bold no more/README.txt new file mode 100644 index 00000000..be2e2151 --- /dev/null +++ b/PROMS/SQL Data Tools/Bold no more/README.txt @@ -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 + + diff --git a/PROMS/SQL Data Tools/Case sensitive text compare.sql b/PROMS/SQL Data Tools/Case sensitive text compare.sql new file mode 100644 index 00000000..054cfecc --- /dev/null +++ b/PROMS/SQL Data Tools/Case sensitive text compare.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Check and Fix Data Issues/script_DataIssuesWithFixes (2022.03.29).sql b/PROMS/SQL Data Tools/Check and Fix Data Issues/script_DataIssuesWithFixes (2022.03.29).sql new file mode 100644 index 00000000..6fd25afd --- /dev/null +++ b/PROMS/SQL Data Tools/Check and Fix Data Issues/script_DataIssuesWithFixes (2022.03.29).sql @@ -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 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 '% 0) + Begin + Update tblContents Set [Text] = Replace([Text], ' 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 '% 0) + Begin + Update tblContents Set [Text] = Replace([Text], ' tags don't match + /*======================================================================================================*/ + Set @IssueNum = 9; + Set @Description = 'Num of 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], '') 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], '') 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 tags don't match + /*======================================================================================================*/ + Set @IssueNum = 10; + Set @Description = 'Num of 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], '') as 'EndCntText', + 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], '') as 'EndCntText', + 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; + + + + + + + + diff --git a/PROMS/SQL Data Tools/CheckAndFixConfigXMLforPSI.sql b/PROMS/SQL Data Tools/CheckAndFixConfigXMLforPSI.sql new file mode 100644 index 00000000..54ba1737 --- /dev/null +++ b/PROMS/SQL Data Tools/CheckAndFixConfigXMLforPSI.sql @@ -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 '%' from Contents where Config like '% ru.rodbid +group by vn.versionid, FolderName, aa.rofstid, rf.rodbid, rf.dts, rd.Roname, rd.folderpath, ru.rodbid +order by rf.dts diff --git a/PROMS/SQL Data Tools/Checking Formats for Page Styles Without the Box Token.sql b/PROMS/SQL Data Tools/Checking Formats for Page Styles Without the Box Token.sql new file mode 100644 index 00000000..8fcd1e7d --- /dev/null +++ b/PROMS/SQL Data Tools/Checking Formats for Page Styles Without the Box Token.sql @@ -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 diff --git a/PROMS/SQL Data Tools/CheckingForNotesCautionsWarningsToSeeHowManyOfEach_RunAfterCheckForNCS.sql b/PROMS/SQL Data Tools/CheckingForNotesCautionsWarningsToSeeHowManyOfEach_RunAfterCheckForNCS.sql new file mode 100644 index 00000000..6396eadb --- /dev/null +++ b/PROMS/SQL Data Tools/CheckingForNotesCautionsWarningsToSeeHowManyOfEach_RunAfterCheckForNCS.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/CleanUpSectionsAAndSteps_CalvertOPS.sql b/PROMS/SQL Data Tools/CleanUpSectionsAAndSteps_CalvertOPS.sql new file mode 100644 index 00000000..e563d3da --- /dev/null +++ b/PROMS/SQL Data Tools/CleanUpSectionsAAndSteps_CalvertOPS.sql @@ -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' + + diff --git a/PROMS/SQL Data Tools/CleanUpSectionsAAndSteps_CalvertSTPs.sql b/PROMS/SQL Data Tools/CleanUpSectionsAAndSteps_CalvertSTPs.sql new file mode 100644 index 00000000..60c124b1 --- /dev/null +++ b/PROMS/SQL Data Tools/CleanUpSectionsAAndSteps_CalvertSTPs.sql @@ -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' + + diff --git a/PROMS/SQL Data Tools/CleanupAssociations.sql b/PROMS/SQL Data Tools/CleanupAssociations.sql new file mode 100644 index 00000000..6f1e2a4f --- /dev/null +++ b/PROMS/SQL Data Tools/CleanupAssociations.sql @@ -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 diff --git a/PROMS/SQL Data Tools/CleanupROUsagesByron.SQL b/PROMS/SQL Data Tools/CleanupROUsagesByron.SQL new file mode 100644 index 00000000..c5b9be12 --- /dev/null +++ b/PROMS/SQL Data Tools/CleanupROUsagesByron.SQL @@ -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 + + diff --git a/PROMS/SQL Data Tools/CleanupROUsagesGinna.SQL b/PROMS/SQL Data Tools/CleanupROUsagesGinna.SQL new file mode 100644 index 00000000..9c781f5c --- /dev/null +++ b/PROMS/SQL Data Tools/CleanupROUsagesGinna.SQL @@ -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 + + diff --git a/PROMS/SQL Data Tools/Compression.sql b/PROMS/SQL Data Tools/Compression.sql new file mode 100644 index 00000000..de00f295 --- /dev/null +++ b/PROMS/SQL Data Tools/Compression.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Compression_stepcompression.sql b/PROMS/SQL Data Tools/Compression_stepcompression.sql new file mode 100644 index 00000000..008ba1b7 --- /dev/null +++ b/PROMS/SQL Data Tools/Compression_stepcompression.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/ConvertEnhanced.sql b/PROMS/SQL Data Tools/ConvertEnhanced.sql new file mode 100644 index 00000000..ed1fb6aa --- /dev/null +++ b/PROMS/SQL Data Tools/ConvertEnhanced.sql @@ -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 ,'>' + ,'>') 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,'>', + '>') + where VersionID =@svid +print 'BGDV-2' +update docversions set config = replace(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,'>', + '>') + where VersionID =@svid +print 'DDDV-2' +update docversions set config = replace(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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/DeleteDisconnectedData.sql b/PROMS/SQL Data Tools/DeleteDisconnectedData.sql new file mode 100644 index 00000000..be068f83 --- /dev/null +++ b/PROMS/SQL Data Tools/DeleteDisconnectedData.sql @@ -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) diff --git a/PROMS/SQL Data Tools/DisconnectGroups.sql b/PROMS/SQL Data Tools/DisconnectGroups.sql new file mode 100644 index 00000000..e73a42a4 --- /dev/null +++ b/PROMS/SQL Data Tools/DisconnectGroups.sql @@ -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) \ No newline at end of file diff --git a/PROMS/SQL Data Tools/DisconnectedStepsandSections.sql b/PROMS/SQL Data Tools/DisconnectedStepsandSections.sql new file mode 100644 index 00000000..42cc4a1d --- /dev/null +++ b/PROMS/SQL Data Tools/DisconnectedStepsandSections.sql @@ -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) \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Find and Fix all Links/1_FindLinkCountSummary.sql b/PROMS/SQL Data Tools/Find and Fix all Links/1_FindLinkCountSummary.sql new file mode 100644 index 00000000..b1e08ad7 --- /dev/null +++ b/PROMS/SQL Data Tools/Find and Fix all Links/1_FindLinkCountSummary.sql @@ -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,'','')))/5 EndCount +, (Len(text)-len(replace(text,'[END>','')))/10 EndEndCount +From Contents) T1 ) t2 +Group By Stat,StartCount,EndCount,StartStartCount,EndEndCount +Order By Stat,StartStartCount,EndEndCount,abs(StartCount-EndCount),StartCount,EndCount \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Find and Fix all Links/2_FindBadLinkFormatStartStart.sql b/PROMS/SQL Data Tools/Find and Fix all Links/2_FindBadLinkFormatStartStart.sql new file mode 100644 index 00000000..243d50de --- /dev/null +++ b/PROMS/SQL Data Tools/Find and Fix all Links/2_FindBadLinkFormatStartStart.sql @@ -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,'','')))/5 EndCount +, (Len(text)-len(replace(text,'[END>','')))/10 EndEndCount +From Contents) T1 ) t2 Where Stat= 1) Order By vi.VersionId,ProcId,Location \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Find and Fix all Links/3_FixBadLinkFormatStartStart.sql b/PROMS/SQL Data Tools/Find and Fix all Links/3_FixBadLinkFormatStartStart.sql new file mode 100644 index 00000000..ac23e5b1 --- /dev/null +++ b/PROMS/SQL Data Tools/Find and Fix all Links/3_FixBadLinkFormatStartStart.sql @@ -0,0 +1,12 @@ +-- Fix Occurences of Links (Transitions or Referenced Objects) where the Start tag is repeated +update Contents set text = Replace(Text,'','')))/5 EndCount +, (Len(text)-len(replace(text,'[END>','')))/10 EndEndCount +From Contents) T1 ) t2 Where Stat= 1) \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Find and Fix all Links/4_FindBadLinkFormatManualFixRequired.sql b/PROMS/SQL Data Tools/Find and Fix all Links/4_FindBadLinkFormatManualFixRequired.sql new file mode 100644 index 00000000..50989a4b --- /dev/null +++ b/PROMS/SQL Data Tools/Find and Fix all Links/4_FindBadLinkFormatManualFixRequired.sql @@ -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,'','')))/5 EndCount +, (Len(text)-len(replace(text,'[END>','')))/10 EndEndCount +From Contents) T1 ) t2 Where Stat= 2) Order By vi.VersionId,ProcId,Location \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindAllHSPinROFST.sql b/PROMS/SQL Data Tools/FindAllHSPinROFST.sql new file mode 100644 index 00000000..70785326 --- /dev/null +++ b/PROMS/SQL Data Tools/FindAllHSPinROFST.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindBadLinkFormatManualFixRequired.sql b/PROMS/SQL Data Tools/FindBadLinkFormatManualFixRequired.sql new file mode 100644 index 00000000..50989a4b --- /dev/null +++ b/PROMS/SQL Data Tools/FindBadLinkFormatManualFixRequired.sql @@ -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,'','')))/5 EndCount +, (Len(text)-len(replace(text,'[END>','')))/10 EndEndCount +From Contents) T1 ) t2 Where Stat= 2) Order By vi.VersionId,ProcId,Location \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindBadLinkFormatStartStart.sql b/PROMS/SQL Data Tools/FindBadLinkFormatStartStart.sql new file mode 100644 index 00000000..16d4d77a --- /dev/null +++ b/PROMS/SQL Data Tools/FindBadLinkFormatStartStart.sql @@ -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,'','')))/5 EndCount +, (Len(text)-len(replace(text,'[END>','')))/10 EndEndCount +From Contents) T1 ) t2 Where Stat= 1) Order By vi.VersionId,ProcId,Location \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindBadROUsageReferences.sql b/PROMS/SQL Data Tools/FindBadROUsageReferences.sql new file mode 100644 index 00000000..8ad2ab74 --- /dev/null +++ b/PROMS/SQL Data Tools/FindBadROUsageReferences.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindLastHLSwithRNOsubstep.sql b/PROMS/SQL Data Tools/FindLastHLSwithRNOsubstep.sql new file mode 100644 index 00000000..9d7a0f9d --- /dev/null +++ b/PROMS/SQL Data Tools/FindLastHLSwithRNOsubstep.sql @@ -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%' \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindLibraryProblems.sql b/PROMS/SQL Data Tools/FindLibraryProblems.sql new file mode 100644 index 00000000..bac8ff7b --- /dev/null +++ b/PROMS/SQL Data Tools/FindLibraryProblems.sql @@ -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 + \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindMatchingTransitionIDs.sql b/PROMS/SQL Data Tools/FindMatchingTransitionIDs.sql new file mode 100644 index 00000000..6a230ec8 --- /dev/null +++ b/PROMS/SQL Data Tools/FindMatchingTransitionIDs.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindMissMatchTransitionIDs.sql b/PROMS/SQL Data Tools/FindMissMatchTransitionIDs.sql new file mode 100644 index 00000000..510600e7 --- /dev/null +++ b/PROMS/SQL Data Tools/FindMissMatchTransitionIDs.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindMissingTransitionIDs.sql b/PROMS/SQL Data Tools/FindMissingTransitionIDs.sql new file mode 100644 index 00000000..b19f504d --- /dev/null +++ b/PROMS/SQL Data Tools/FindMissingTransitionIDs.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindROProblems.sql b/PROMS/SQL Data Tools/FindROProblems.sql new file mode 100644 index 00000000..75817259 --- /dev/null +++ b/PROMS/SQL Data Tools/FindROProblems.sql @@ -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 diff --git a/PROMS/SQL Data Tools/FindROStatus.sql b/PROMS/SQL Data Tools/FindROStatus.sql new file mode 100644 index 00000000..058bec65 --- /dev/null +++ b/PROMS/SQL Data Tools/FindROStatus.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindROTables.sql b/PROMS/SQL Data Tools/FindROTables.sql new file mode 100644 index 00000000..956edeef --- /dev/null +++ b/PROMS/SQL Data Tools/FindROTables.sql @@ -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 '%True%' \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindSQLVersion.sql b/PROMS/SQL Data Tools/FindSQLVersion.sql new file mode 100644 index 00000000..bfb97614 --- /dev/null +++ b/PROMS/SQL Data Tools/FindSQLVersion.sql @@ -0,0 +1 @@ + RESTORE HEADERONLY FROM DISK = 'C:\Folder Shares\04 VEPROMS FILES\Active Project Files\' \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindSectionCautionsNotesAndWarnings.sql b/PROMS/SQL Data Tools/FindSectionCautionsNotesAndWarnings.sql new file mode 100644 index 00000000..525484e4 --- /dev/null +++ b/PROMS/SQL Data Tools/FindSectionCautionsNotesAndWarnings.sql @@ -0,0 +1 @@ +select * from Contents where type in(20021,20023,20026) \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindSectionsAndSteps_CalvertSTPs.sql b/PROMS/SQL Data Tools/FindSectionsAndSteps_CalvertSTPs.sql new file mode 100644 index 00000000..587ab852 --- /dev/null +++ b/PROMS/SQL Data Tools/FindSectionsAndSteps_CalvertSTPs.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindSquaresInTables_BwdAndByrSep2016.sql b/PROMS/SQL Data Tools/FindSquaresInTables_BwdAndByrSep2016.sql new file mode 100644 index 00000000..76d6257f --- /dev/null +++ b/PROMS/SQL Data Tools/FindSquaresInTables_BwdAndByrSep2016.sql @@ -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;}%' \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindStrangeSectionTitles.sql b/PROMS/SQL Data Tools/FindStrangeSectionTitles.sql new file mode 100644 index 00000000..3942121c --- /dev/null +++ b/PROMS/SQL Data Tools/FindStrangeSectionTitles.sql @@ -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]' \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindStrangeTables.sql b/PROMS/SQL Data Tools/FindStrangeTables.sql new file mode 100644 index 00000000..ceab8fee --- /dev/null +++ b/PROMS/SQL Data Tools/FindStrangeTables.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindTablesWithDuplicateROUsages.sql b/PROMS/SQL Data Tools/FindTablesWithDuplicateROUsages.sql new file mode 100644 index 00000000..5b471d58 --- /dev/null +++ b/PROMS/SQL Data Tools/FindTablesWithDuplicateROUsages.sql @@ -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)) + '%' \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindTransitionsToUneditableStepText.sql b/PROMS/SQL Data Tools/FindTransitionsToUneditableStepText.sql new file mode 100644 index 00000000..ea411182 --- /dev/null +++ b/PROMS/SQL Data Tools/FindTransitionsToUneditableStepText.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindUneditableStepText.sql b/PROMS/SQL Data Tools/FindUneditableStepText.sql new file mode 100644 index 00000000..d59dfbd7 --- /dev/null +++ b/PROMS/SQL Data Tools/FindUneditableStepText.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FindinglocationsofduplicateTransitions.sql b/PROMS/SQL Data Tools/FindinglocationsofduplicateTransitions.sql new file mode 100644 index 00000000..756aa2e0 --- /dev/null +++ b/PROMS/SQL Data Tools/FindinglocationsofduplicateTransitions.sql @@ -0,0 +1,2 @@ +select * from contents where text like '%\\v0 \.\\v%' escape '\' + diff --git a/PROMS/SQL Data Tools/FixBadLinkFormatStartStart.sql b/PROMS/SQL Data Tools/FixBadLinkFormatStartStart.sql new file mode 100644 index 00000000..e0dbf33c --- /dev/null +++ b/PROMS/SQL Data Tools/FixBadLinkFormatStartStart.sql @@ -0,0 +1,12 @@ +-- Fix Occurences of Links (Trnasitions or Referenced Objects) where the Start tag ins repeated +update Contents set text = Replace(Text,'','')))/5 EndCount +, (Len(text)-len(replace(text,'[END>','')))/10 EndEndCount +From Contents) T1 ) t2 Where Stat= 1) \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FixLibDocs.sql b/PROMS/SQL Data Tools/FixLibDocs.sql new file mode 100644 index 00000000..49789ad7 --- /dev/null +++ b/PROMS/SQL Data Tools/FixLibDocs.sql @@ -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) \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FixMissingFigures_CallawayMissingImages_Jan2016.sql b/PROMS/SQL Data Tools/FixMissingFigures_CallawayMissingImages_Jan2016.sql new file mode 100644 index 00000000..979e4231 --- /dev/null +++ b/PROMS/SQL Data Tools/FixMissingFigures_CallawayMissingImages_Jan2016.sql @@ -0,0 +1,12 @@ +INSERT INTO [dbo].[Figures] + ([ROFstID] + ,[ImageID] + ,[Config] + ,[DTS] + ,[UserID]) + Select 76 + ,[ImageID] + ,[Config] + ,[DTS] + ,[UserID] from FIgures where ROFSTID=74 + \ No newline at end of file diff --git a/PROMS/SQL Data Tools/FixROProblems.sql b/PROMS/SQL Data Tools/FixROProblems.sql new file mode 100644 index 00000000..e524c16b --- /dev/null +++ b/PROMS/SQL Data Tools/FixROProblems.sql @@ -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*/ diff --git a/PROMS/SQL Data Tools/GetRODBsAndROFSTsAndAssociations.sql b/PROMS/SQL Data Tools/GetRODBsAndROFSTsAndAssociations.sql new file mode 100644 index 00000000..e4e1e5c3 --- /dev/null +++ b/PROMS/SQL Data Tools/GetRODBsAndROFSTsAndAssociations.sql @@ -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 +*/ \ No newline at end of file diff --git a/PROMS/SQL Data Tools/GetVersionIDandProcID.sql b/PROMS/SQL Data Tools/GetVersionIDandProcID.sql new file mode 100644 index 00000000..636f6281 --- /dev/null +++ b/PROMS/SQL Data Tools/GetVersionIDandProcID.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/GetVersionItemsIncludingDeleted.sql b/PROMS/SQL Data Tools/GetVersionItemsIncludingDeleted.sql new file mode 100644 index 00000000..a78aa71a --- /dev/null +++ b/PROMS/SQL Data Tools/GetVersionItemsIncludingDeleted.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Grids/FindInconsistentRowsAndColumns.sql b/PROMS/SQL Data Tools/Grids/FindInconsistentRowsAndColumns.sql new file mode 100644 index 00000000..5811656f --- /dev/null +++ b/PROMS/SQL Data Tools/Grids/FindInconsistentRowsAndColumns.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/How many changes were made to the data within a range.sql b/PROMS/SQL Data Tools/How many changes were made to the data within a range.sql new file mode 100644 index 00000000..c0f9ae59 --- /dev/null +++ b/PROMS/SQL Data Tools/How many changes were made to the data within a range.sql @@ -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) \ No newline at end of file diff --git a/PROMS/SQL Data Tools/IP3 integrated graphic usage.sql b/PROMS/SQL Data Tools/IP3 integrated graphic usage.sql new file mode 100644 index 00000000..0da43025 --- /dev/null +++ b/PROMS/SQL Data Tools/IP3 integrated graphic usage.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/ListWordDocSizesAndIds.sql b/PROMS/SQL Data Tools/ListWordDocSizesAndIds.sql new file mode 100644 index 00000000..d1b6ed30 --- /dev/null +++ b/PROMS/SQL Data Tools/ListWordDocSizesAndIds.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Looking for section formats used by format name_ALN.sql b/PROMS/SQL Data Tools/Looking for section formats used by format name_ALN.sql new file mode 100644 index 00000000..6a2efc76 --- /dev/null +++ b/PROMS/SQL Data Tools/Looking for section formats used by format name_ALN.sql @@ -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) diff --git a/PROMS/SQL Data Tools/Merging data into a database.sql b/PROMS/SQL Data Tools/Merging data into a database.sql new file mode 100644 index 00000000..2ce687ee --- /dev/null +++ b/PROMS/SQL Data Tools/Merging data into a database.sql @@ -0,0 +1 @@ +sp_changedbowner sa \ No newline at end of file diff --git a/PROMS/SQL Data Tools/PI RO Table Items 82714.sql b/PROMS/SQL Data Tools/PI RO Table Items 82714.sql new file mode 100644 index 00000000..3c7ef3b9 --- /dev/null +++ b/PROMS/SQL Data Tools/PI RO Table Items 82714.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/PurgeChangeManager.sql b/PROMS/SQL Data Tools/PurgeChangeManager.sql new file mode 100644 index 00000000..15481ec1 --- /dev/null +++ b/PROMS/SQL Data Tools/PurgeChangeManager.sql @@ -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 diff --git a/PROMS/SQL Data Tools/Queries to Shrink DBs/CleanUpPROMS.sql b/PROMS/SQL Data Tools/Queries to Shrink DBs/CleanUpPROMS.sql new file mode 100644 index 00000000..f80f2a3b --- /dev/null +++ b/PROMS/SQL Data Tools/Queries to Shrink DBs/CleanUpPROMS.sql @@ -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 diff --git a/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.04.12).sql b/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.04.12).sql new file mode 100644 index 00000000..27c31d72 --- /dev/null +++ b/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.04.12).sql @@ -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 diff --git a/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.04.13).sql b/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.04.13).sql new file mode 100644 index 00000000..707a2a1b --- /dev/null +++ b/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.04.13).sql @@ -0,0 +1,1047 @@ + + +/****** Object: StoredProcedure [dbo].[vesp_RofstHeaderInsert] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstHeaderInsert]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstHeaderInsert] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetRofstByID] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetRofstByID]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstDataGetRofstByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetDatabases] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetDatabases]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstDataGetDatabases] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetDatabaseByID] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetDatabaseByID]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstDataGetDatabaseByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRoid] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildrenByRoid]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstDataGetChildrenByRoid] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRofstID] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildrenByRofstID]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstDataGetChildrenByRofstID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByID] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildrenByID]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstDataGetChildrenByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByRoid] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildByRoid]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstDataGetChildByRoid] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByID] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildByID]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstDataGetChildByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByAccPageID] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildByAccPageID]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstDataGetChildByAccPageID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataExists] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstDataExists]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstDataExists] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDatabaseInsert] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstDatabaseInsert]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstDatabaseInsert] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstChildInsert] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vesp_RofstChildInsert]') AND type in (N'P', N'PC')) +DROP PROCEDURE [dbo].[vesp_RofstChildInsert] +GO +IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RofstHeader_ROFsts]') AND parent_object_id = OBJECT_ID(N'[dbo].[RofstHeader]')) +ALTER TABLE [dbo].[RofstHeader] DROP CONSTRAINT [FK_RofstHeader_ROFsts] +GO +IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RofstDatabase_RofstHeader]') AND parent_object_id = OBJECT_ID(N'[dbo].[RofstDatabase]')) +ALTER TABLE [dbo].[RofstDatabase] DROP CONSTRAINT [FK_RofstDatabase_RofstHeader] +GO +IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RofstChild_RofstDatabase]') AND parent_object_id = OBJECT_ID(N'[dbo].[RofstChild]')) +ALTER TABLE [dbo].[RofstChild] DROP CONSTRAINT [FK_RofstChild_RofstDatabase] +GO +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DF_RofstHeader_CreateDate]') AND type = 'D') +BEGIN +ALTER TABLE [dbo].[RofstHeader] DROP CONSTRAINT [DF_RofstHeader_CreateDate] +END +GO +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DF_RofstHeader_CreateUserID]') AND type = 'D') +BEGIN +ALTER TABLE [dbo].[RofstHeader] DROP CONSTRAINT [DF_RofstHeader_CreateUserID] +END +GO +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DF_RofstDatabase_ParentID]') AND type = 'D') +BEGIN +ALTER TABLE [dbo].[RofstDatabase] DROP CONSTRAINT [DF_RofstDatabase_ParentID] +END +GO +/****** Object: Index [IX_RofstID_Roid] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[RofstChild]') AND name = N'IX_RofstID_Roid') +DROP INDEX [IX_RofstID_Roid] ON [dbo].[RofstChild] +GO +/****** Object: Index [IX_RofstID_DbiID_ParentID] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[RofstChild]') AND name = N'IX_RofstID_DbiID_ParentID') +DROP INDEX [IX_RofstID_DbiID_ParentID] ON [dbo].[RofstChild] +GO +/****** Object: View [dbo].[vwRofstData_RofstHeaders] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vwRofstData_RofstHeaders]')) +DROP VIEW [dbo].[vwRofstData_RofstHeaders] +GO +/****** Object: View [dbo].[vwRofstData_RofstGroups] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vwRofstData_RofstGroups]')) +DROP VIEW [dbo].[vwRofstData_RofstGroups] +GO +/****** Object: View [dbo].[vwRofstData_RofstDatabases] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vwRofstData_RofstDatabases]')) +DROP VIEW [dbo].[vwRofstData_RofstDatabases] +GO +/****** Object: View [dbo].[vwRofstData_RofstChildren] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vwRofstData_RofstChildren]')) +DROP VIEW [dbo].[vwRofstData_RofstChildren] +GO +/****** Object: Table [dbo].[RofstHeader] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RofstHeader]') AND type in (N'U')) +DROP TABLE [dbo].[RofstHeader] +GO +/****** Object: Table [dbo].[RofstDatabase] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RofstDatabase]') AND type in (N'U')) +DROP TABLE [dbo].[RofstDatabase] +GO +/****** Object: Table [dbo].[RofstChild] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RofstChild]') AND type in (N'U')) +DROP TABLE [dbo].[RofstChild] +GO + +/****** Object: UserDefinedFunction [dbo].[vefn_ParseStringListToTable] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vefn_ParseStringListToTable]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT')) +DROP FUNCTION [dbo].[vefn_ParseStringListToTable] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_NumOfOccurrences] Script Date: 4/13/2022 2:38:17 PM ******/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vefn_NumOfOccurrences]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT')) +DROP FUNCTION [dbo].[vefn_NumOfOccurrences] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_NumOfOccurrences] Script Date: 4/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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: Table [dbo].[RofstHeader] Script Date: 4/13/2022 2:38:17 PM ******/ +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_RofstChildren] Script Date: 4/13/2022 2:38:17 PM ******/ +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', + -- RoDatabase Info + rd.dbiID as 'dbiID', + rd.dbiType as 'dbiType', + rd.dbiAW as 'dbiAW', + rd.dbiTitle as 'dbiTitle', + rd.dbiAP as 'dbiAP', + -- RoChild Info + 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: View [dbo].[vwRofstData_RofstDatabases] Script Date: 4/13/2022 2:38:17 PM ******/ +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: View [dbo].[vwRofstData_RofstGroups] Script Date: 4/13/2022 2:38:17 PM ******/ +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', + -- RoDatabase Info + rd.dbiID as 'dbiID', + rd.dbiType as 'dbiType', + rd.dbiAW as 'dbiAW', + rd.dbiTitle as 'dbiTitle', + rd.dbiAP as 'dbiAP', + -- RoChild Info + 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_RofstHeaders] Script Date: 4/13/2022 2:38:17 PM ******/ +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: Index [IX_RofstID_DbiID_ParentID] Script Date: 4/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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_RofstDataGetChildrenByID] Script Date: 4/13/2022 2:38:17 PM ******/ +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_RofstDataGetChildrenByID] +( + @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.ParentID = @ID + Order By rc.ID Asc; + + +Return; +End + +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRofstID] Script Date: 4/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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/13/2022 2:38:17 PM ******/ +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 diff --git a/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.04.26).sql b/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.04.26).sql new file mode 100644 index 00000000..8febbbf2 --- /dev/null +++ b/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.04.26).sql @@ -0,0 +1,1486 @@ + + + + + +/* Make the ROLookup column nullable in ROFsts*/ +BEGIN TRANSACTION +SET QUOTED_IDENTIFIER ON +SET ARITHABORT ON +SET NUMERIC_ROUNDABORT OFF +SET CONCAT_NULL_YIELDS_NULL ON +SET ANSI_NULLS ON +SET ANSI_PADDING ON +SET ANSI_WARNINGS ON +COMMIT +BEGIN TRANSACTION +GO +ALTER TABLE dbo.ROFsts + DROP CONSTRAINT FK_ROFsts_RODbs +GO +ALTER TABLE dbo.RODbs SET (LOCK_ESCALATION = TABLE) +GO +COMMIT +select Has_Perms_By_Name(N'dbo.RODbs', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.RODbs', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.RODbs', 'Object', 'CONTROL') as Contr_Per BEGIN TRANSACTION +GO +ALTER TABLE dbo.ROFsts + DROP CONSTRAINT DF_Table_1_DTS1 +GO +ALTER TABLE dbo.ROFsts + DROP CONSTRAINT DF_ROFsts_UserID +GO +CREATE TABLE dbo.Tmp_ROFsts + ( + ROFstID int NOT NULL IDENTITY (1, 1), + RODbID int NOT NULL, + ROLookup varbinary(MAX) NULL, + Config nvarchar(MAX) NULL, + DTS datetime NOT NULL, + UserID nvarchar(100) NOT NULL, + LastChanged timestamp NOT NULL + ) ON [PRIMARY] + TEXTIMAGE_ON [PRIMARY] +GO +ALTER TABLE dbo.Tmp_ROFsts SET (LOCK_ESCALATION = TABLE) +GO +DECLARE @v sql_variant +SET @v = N'{datetime}' +EXECUTE sp_addextendedproperty N'MS_Description', @v, N'SCHEMA', N'dbo', N'TABLE', N'Tmp_ROFsts', N'COLUMN', N'DTS' +GO +ALTER TABLE dbo.Tmp_ROFsts ADD CONSTRAINT + DF_Table_1_DTS1 DEFAULT (getdate()) FOR DTS +GO +ALTER TABLE dbo.Tmp_ROFsts ADD CONSTRAINT + DF_ROFsts_UserID DEFAULT (upper(suser_sname())) FOR UserID +GO +SET IDENTITY_INSERT dbo.Tmp_ROFsts ON +GO +IF EXISTS(SELECT * FROM dbo.ROFsts) + EXEC('INSERT INTO dbo.Tmp_ROFsts (ROFstID, RODbID, ROLookup, Config, DTS, UserID) + SELECT ROFstID, RODbID, ROLookup, Config, DTS, UserID FROM dbo.ROFsts WITH (HOLDLOCK TABLOCKX)') +GO +SET IDENTITY_INSERT dbo.Tmp_ROFsts OFF +GO +ALTER TABLE dbo.Associations + DROP CONSTRAINT FK_Associations_ROFsts +GO +ALTER TABLE dbo.Figures + DROP CONSTRAINT FK_Figures_ROFsts +GO +DROP TABLE dbo.ROFsts +GO +EXECUTE sp_rename N'dbo.Tmp_ROFsts', N'ROFsts', 'OBJECT' +GO +ALTER TABLE dbo.ROFsts ADD CONSTRAINT + PK_ROFsts PRIMARY KEY CLUSTERED + ( + ROFstID + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] + +GO +CREATE UNIQUE NONCLUSTERED INDEX IX_ROFsts ON dbo.ROFsts + ( + RODbID, + DTS + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +GO +ALTER TABLE dbo.ROFsts ADD CONSTRAINT + FK_ROFsts_RODbs FOREIGN KEY + ( + RODbID + ) REFERENCES dbo.RODbs + ( + RODbID + ) ON UPDATE NO ACTION + ON DELETE NO ACTION + +GO +COMMIT +select Has_Perms_By_Name(N'dbo.ROFsts', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.ROFsts', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.ROFsts', 'Object', 'CONTROL') as Contr_Per BEGIN TRANSACTION +GO +ALTER TABLE dbo.Figures ADD CONSTRAINT + FK_Figures_ROFsts FOREIGN KEY + ( + ROFstID + ) REFERENCES dbo.ROFsts + ( + ROFstID + ) ON UPDATE NO ACTION + ON DELETE NO ACTION + +GO +ALTER TABLE dbo.Figures SET (LOCK_ESCALATION = TABLE) +GO +COMMIT +select Has_Perms_By_Name(N'dbo.Figures', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.Figures', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.Figures', 'Object', 'CONTROL') as Contr_Per BEGIN TRANSACTION +GO +ALTER TABLE dbo.Associations ADD CONSTRAINT + FK_Associations_ROFsts FOREIGN KEY + ( + ROFstID + ) REFERENCES dbo.ROFsts + ( + ROFstID + ) ON UPDATE NO ACTION + ON DELETE NO ACTION + +GO +ALTER TABLE dbo.Associations SET (LOCK_ESCALATION = TABLE) +GO +COMMIT +select Has_Perms_By_Name(N'dbo.Associations', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.Associations', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.Associations', 'Object', 'CONTROL') as Contr_Per + + + + + + +/****** Object: StoredProcedure [dbo].[vesp_RofstHeaderInsert] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstHeaderInsert] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataSearch] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataSearch] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetValueDifferences] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetValueDifferences] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetRofstByID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetRofstByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetDatabases] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetDatabases] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetDatabaseByID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetDatabaseByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRoid] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildrenByRoid] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRofstID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildrenByRofstID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildrenByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByRoid] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildByRoid] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByAccPageID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildByAccPageID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataExists] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataExists] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDatabaseInsert] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDatabaseInsert] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstChildInsert] Script Date: 4/26/2022 6:59:49 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].[RofstDefaultValue]') AND type in (N'U')) +ALTER TABLE [dbo].[RofstDefaultValue] DROP CONSTRAINT IF EXISTS [FK_RofstDefaultValue_RofstHeader] +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/26/2022 6:59:49 AM ******/ +DROP INDEX IF EXISTS [IX_RofstID_Roid] ON [dbo].[RofstChild] +GO +/****** Object: Index [IX_RofstID_DbiID_ParentID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP INDEX IF EXISTS [IX_RofstID_DbiID_ParentID] ON [dbo].[RofstChild] +GO +/****** Object: View [dbo].[vwRofstData_RofstDatabases] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstDatabases] +GO +/****** Object: View [dbo].[vwRofstData_RofstHeaders] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstHeaders] +GO +/****** Object: Table [dbo].[RofstHeader] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP TABLE IF EXISTS [dbo].[RofstHeader] +GO +/****** Object: View [dbo].[vwRofstData_RofstChildren] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstChildren] +GO +/****** Object: View [dbo].[vwRofstData_RofstGroups] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstGroups] +GO +/****** Object: Table [dbo].[RofstDatabase] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP TABLE IF EXISTS [dbo].[RofstDatabase] +GO +/****** Object: Table [dbo].[RofstChild] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP TABLE IF EXISTS [dbo].[RofstChild] +GO +/****** Object: View [dbo].[vwRofstData_RofstDefaultValues] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstDefaultValues] +GO +/****** Object: Table [dbo].[RofstDefaultValue] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP TABLE IF EXISTS [dbo].[RofstDefaultValue] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceVars] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP FUNCTION IF EXISTS [dbo].[vefn_RofstDataReplaceVars] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceApplTagsWithDefaults] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP FUNCTION IF EXISTS [dbo].[vefn_RofstDataReplaceApplTagsWithDefaults] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_NumOfOccurrences] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP FUNCTION IF EXISTS [dbo].[vefn_NumOfOccurrences] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_Clean] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP FUNCTION IF EXISTS [dbo].[vefn_Clean] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_Clean] Script Date: 4/26/2022 6:59:49 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 4/21/2022 +-- Description: Cleans (Trim) the string value passed +-- Optional: Truncate is string is passed a specified max length +-- Optional: Convert any null values to an empty string or leave as null +-- ========================================================================================== + +Create Function [dbo].[vefn_Clean] ( @Value VarChar(Max), @ConvertNulls bit = 0, @MaxLength Int = null ) +Returns VarChar(Max) +As +Begin + + Declare @RetVal VarChar(Max); + + If (Len(IsNull(@Value,'')) > 0) + Begin + + Set @RetVal = LTrim(RTrim(@Value)); + If (Not @MaxLength is null And Len(@RetVal) > @MaxLength) Set @RetVal = Left(@RetVal, @MaxLength); + + End + + If (@ConvertNulls = 1) + Set @RetVal = IsNull(@RetVal, ''); + + Return @RetVal; + +End +GO +/****** Object: UserDefinedFunction [dbo].[vefn_NumOfOccurrences] Script Date: 4/26/2022 6:59:49 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_RofstDataReplaceApplTagsWithDefaults] Script Date: 4/26/2022 6:59:49 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 3/25/2022 +-- Description: Replaces any "" tags with the default value +-- ========================================================================================== + +CREATE FUNCTION [dbo].[vefn_RofstDataReplaceApplTagsWithDefaults](@Values VarChar(Max)) Returns VarChar(Max) +WITH EXECUTE AS OWNER +AS +BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @DefaultValue VarChar(Max) = ''; + + Declare @StartTagIndex Int; + Declare @EndTagIndex Int; + Declare @StartTagValue VarChar(Max); + + Set @RetVal = @Values; + Set @StartTagIndex = PatIndex('%%', @RetVal); + + While (@StartTagIndex > 0) + Begin + + Set @StartTagValue = SubString(@RetVal, @StartTagIndex, (@EndTagIndex - @StartTagIndex) + 5); + Set @DefaultValue = Replace(@StartTagValue, '%', @DefaultValue); + + Set @DefaultValue = RTrim(SubString(@DefaultValue, 0, @EndTagIndex)); + Set @RetVal = Replace(@RetVal, @StartTagValue, @DefaultValue); + + Set @StartTagIndex = PatIndex('%%', @RetVal); + + End -- While (@StartTagIndex > 0) + + Return @RetVal; + +END +GO +/****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceVars] Script Date: 4/26/2022 6:59:49 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 3/25/2022 +-- Description: Replaces Any Variables and returns the rest of the value string +-- ========================================================================================== + +CREATE FUNCTION [dbo].[vefn_RofstDataReplaceVars](@Values VarChar(Max)) Returns VarChar(Max) +WITH EXECUTE AS OWNER +AS +BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @EqualsIndex Int; + Declare @EndIndex Int; + Declare @NameValPairStartIndex Int; + Declare @NameValPairEndIndex Int; + + Declare @VarPair VarChar(Max); + Declare @VarName VarChar(Max); + Declare @VarValue VarChar(Max); + + -- Replace Any "" Tags with the Default Value first + Select @RetVal = dbo.vefn_RofstDataReplaceApplTagsWithDefaults(@Values); + + If (PatIndex('%{{A%', @RetVal) > 0) + Set @EndIndex = PatIndex('%{{A%', @RetVal); + Else + Set @EndIndex = Len(@RetVal) -1; + + Set @NameValPairStartIndex = PatIndex('%{%', @RetVal); + Set @NameValPairEndIndex = PatIndex('%}%', @RetVal); + + While(@NameValPairStartIndex > 0 And @NameValPairStartIndex < @EndIndex) + Begin + + -- Get Name Value Pair [ex. {EGS=1214}] + Set @VarPair = SubString(@RetVal, @NameValPairStartIndex, (@NameValPairEndIndex - @NameValPairStartIndex) + 1); + + -- Remove Name Value Pair From Return Val + Set @RetVal = Replace(@RetVal, @VarPair, ''); + + -- Get Variable Name and Value + Set @EqualsIndex = PatIndex('%=%', @VarPair); + + If (@EqualsIndex > 0) + Begin + Set @VarName = SubString(@VarPair, 2, @EqualsIndex - 2); + Set @VarValue = SubString(@VarPair, @EqualsIndex + 1, Len(@VarPair) - @EqualsIndex - 1); + Set @VarName = Concat('{', @VarName, '}'); + + -- Replace All Occurences + Set @RetVal = Replace(@RetVal, @VarName, @VarValue); + End + + -- Get Updated Index Values + If (PatIndex('%{{A%', @RetVal) > 0) + Set @EndIndex = PatIndex('%{{A%', @RetVal); + Else + Set @EndIndex = Len(@RetVal) -1; + + Set @NameValPairStartIndex = PatIndex('%{%', @RetVal); + Set @NameValPairEndIndex = PatIndex('%}%', @RetVal); + + End -- End While(@ReplaceVarEndTagIndex > 0) + + Return @RetVal; + +END +GO +/****** Object: Table [dbo].[RofstDefaultValue] Script Date: 4/26/2022 6:59:49 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[RofstDefaultValue]( + [RofstID] [int] NOT NULL, + [roid] [varchar](50) NOT NULL, + [value] [varchar](max) NOT NULL, + [AccPageID] [varchar](max) NULL, + CONSTRAINT [PK_RofstDefaultValue] PRIMARY KEY CLUSTERED +( + [RofstID] ASC, + [roid] 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_RofstDefaultValues] Script Date: 4/26/2022 6:59:50 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 Rofst Roid Default Values +========================================================================================================== +*/ +Create View [dbo].[vwRofstData_RofstDefaultValues] +As + + Select rdv.RofstID as 'RofstID', + rdv.roid as 'roid', + rdv.[value] as 'value', + rdv.AccPageID as 'AccPageID' + From RofstDefaultValue rdv With (NoLock) + + + +GO +/****** Object: Table [dbo].[RofstChild] Script Date: 4/26/2022 6:59:50 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/26/2022 6:59:50 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_RofstGroups] Script Date: 4/26/2022 6:59:50 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', + -- RoDatabase Info + rd.dbiID as 'dbiID', + rd.dbiType as 'dbiType', + rd.dbiAW as 'dbiAW', + rd.dbiTitle as 'dbiTitle', + rd.dbiAP as 'dbiAP', + -- RoChild Info + 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_RofstChildren] Script Date: 4/26/2022 6:59:50 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', + -- RoDatabase Info + rd.dbiID as 'dbiID', + rd.dbiType as 'dbiType', + rd.dbiAW as 'dbiAW', + rd.dbiTitle as 'dbiTitle', + rd.dbiAP as 'dbiAP', + -- RoChild Info + 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/26/2022 6:59:50 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, + [ROLookup] [varbinary](max) 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] TEXTIMAGE_ON [PRIMARY] +GO +/****** Object: View [dbo].[vwRofstData_RofstHeaders] Script Date: 4/26/2022 6:59:50 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_RofstDatabases] Script Date: 4/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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].[RofstDefaultValue] WITH CHECK ADD CONSTRAINT [FK_RofstDefaultValue_RofstHeader] FOREIGN KEY([RofstID]) +REFERENCES [dbo].[RofstHeader] ([RofstID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[RofstDefaultValue] CHECK CONSTRAINT [FK_RofstDefaultValue_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/26/2022 6:59:50 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 + + Declare @AccPageID VarChar(Max) = null; + Declare @DefaultValues VarChar(Max); + + + -- 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); + + + -- Check for appid, if exists, then insert the default value for each return type if multi-value + If (Len(@appid) > 0) + Begin + + -- Get Accessory Page ID + Select @AccPageID = Concat(d.dbiAP, '-', @appid) + From RofstDatabase d with (NoLock) + Where d.RofstID = @RofstID And d.dbiID = @dbiID; + + -- Insert Rofst Default Value (Parent RoChild) [roid = 12] + Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) + Values (@RofstID, @roid, Replace(@title, '\u160?', ' '), @AccPageID); + + -- Insert Rofst Default Value(s) (Children RoChild) [roid = 16] (Do Not Insert Duplicates) + Select @DefaultValues = Replace(dbo.vefn_RofstDataReplaceVars(@value), '{', ''); + + With ChildrenValues as + ( + Select (x.ListPosition - 1) as 'OffsetIndex', + Case When (PatIndex('%=%', x.ListValue) > 0) Then Right(x.ListValue, Len(x.ListValue)-PatIndex('%=%', x.ListValue)) Else x.ListValue End as 'DefaultValue' + From [dbo].[vefn_ParseStringListToTable](@DefaultValues, '}') x + Where Len(x.ListValue) > 0 + ) + Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) + Select @RofstID as 'RofstID', + Concat(@roid, Cast(Format(Min(OffsetIndex), 'D4') as VarChar(4))) as 'roid', + DefaultValue as 'value', + null as 'AccPageID' + From ChildrenValues + Group By DefaultValue + Order By Min(OffsetIndex) Asc + + End -- (Len(@appid) > 0) + + + Return; + +End +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDatabaseInsert] Script Date: 4/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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_RofstDataGetChildrenByID] Script Date: 4/26/2022 6:59:50 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_RofstDataGetChildrenByID] +( + @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.ParentID = @ID + Order By rc.ID Asc; + + +Return; +End + +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRofstID] Script Date: 4/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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_RofstDataGetValueDifferences] Script Date: 4/26/2022 6:59:50 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_RofstDataGetValueDifferences] +( + @OriginalRofstID Int, + @CurrentRofstID Int +) +With Execute as Owner +As +Begin + + Declare @Differences Table (OriginalRoid VarChar(25), OriginalValue VarChar(Max), + CurrentRoid VarChar(25), CurrentValue VarChar(Max)); + + + With OriginalRofst as + ( + Select rc.roid, rc.[value] + From vwRofstData_RofstChildren rc + Where rc.RofstID = @OriginalRofstID + And Not rc.[value] is null + + ), CurrentRofst as ( + + Select rc.roid, rc.[value] + From vwRofstData_RofstChildren rc + Where rc.RofstID = @CurrentRofstID + And Not rc.[value] is null + ) + Insert Into @Differences (OriginalRoid, OriginalValue, CurrentRoid, CurrentValue) + Select o.roid, o.[value], c.roid, c.[value] + From OriginalRofst o + left outer join CurrentRofst c on c.roid = o.roid + Where o.[value] <> c.[value]; + + + Select OriginalRoid as 'Roid', + Case When (CurrentValue is null) Then 1 Else 0 End as 'IsDeleted', + Case When (Not CurrentValue is null) Then 1 Else 0 End as 'IsModified' + From @Differences; + + +Return; +End + +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataSearch] Script Date: 4/26/2022 6:59:50 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: RO Default Value Search + + @SearchTypeID => (1) Exact Match (2) Starts With (3) Ends With (4) Contains +========================================================================================================== + */ +Create Procedure [dbo].[vesp_RofstDataSearch] +( + @RofstID int, + @Value VarChar(Max) = null, + @SearchTypeID Int = 1 +) +With Execute as Owner +As +Begin + + -- Remove any leading/trailing white spaces + Set @Value = dbo.vefn_Clean( @Value, 0, null ); + + -- Escape any % signs in the search value + Set @Value = Replace( @Value, '%', '[%]' ); + + -- Format search value + If (Len(@Value) = 0) Set @Value = null; + + + Select rdv.RofstID, + rdv.roid, + rdv.[value] + From vwRofstData_RofstDefaultValues rdv + Where (@SearchTypeID = 1 And (@Value is null Or rdv.[value] = @Value)) + Or (@SearchTypeID = 2 And (@Value is null Or rdv.[value] like @Value + '%')) + Or (@SearchTypeID = 3 And (@Value is null Or rdv.[value] like '%' + @Value)) + Or (@SearchTypeID = 4 And (@Value is null Or rdv.[value] like '%' + @Value + '%')) + Option (Recompile) + + +Return; +End + +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstHeaderInsert] Script Date: 4/26/2022 6:59:50 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, ROLookup, CreateUserID, CreateDate) + Values (@RofstID, @hSize, @hMonth, @hDay, @hcYear, @hcMonth, @hcDay, @hcHour, @hcMin, @hcSec, @hcHund, null, @UserID, GetDate()); + + -- Copy over Binary + Update RofstHeader + Set ROLookup = r.ROLookup + From ROFsts r with (NoLock) + Where r.ROFstID = @RofstID; + + -- Delete from Main ROFsts for now + Update ROFsts + Set ROLookup = null + Where ROFstID = @RofstID; + +Return; +End + +GO + + diff --git a/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.04.27).sql b/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.04.27).sql new file mode 100644 index 00000000..85e3a5fc --- /dev/null +++ b/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.04.27).sql @@ -0,0 +1,1580 @@ + + +/****** Object: StoredProcedure [dbo].[vesp_RofstHeaderInsert] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstHeaderInsert] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataSearch] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataSearch] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetValueDifferences] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetValueDifferences] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetRofstByID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetRofstByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetDatabases] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetDatabases] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetDatabaseByID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetDatabaseByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRoid] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildrenByRoid] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRofstID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildrenByRofstID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildrenByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByRoid] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildByRoid] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByAccPageID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildByAccPageID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataExists] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataExists] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDatabaseInsert] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDatabaseInsert] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstChildInsert] Script Date: 4/26/2022 6:59:49 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].[RofstDefaultValue]') AND type in (N'U')) +ALTER TABLE [dbo].[RofstDefaultValue] DROP CONSTRAINT IF EXISTS [FK_RofstDefaultValue_RofstHeader] +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/26/2022 6:59:49 AM ******/ +DROP INDEX IF EXISTS [IX_RofstID_Roid] ON [dbo].[RofstChild] +GO +/****** Object: Index [IX_RofstID_DbiID_ParentID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP INDEX IF EXISTS [IX_RofstID_DbiID_ParentID] ON [dbo].[RofstChild] +GO +/****** Object: View [dbo].[vwRofstData_RofstDatabases] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstDatabases] +GO +/****** Object: View [dbo].[vwRofstData_RofstHeaders] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstHeaders] +GO +/****** Object: Table [dbo].[RofstHeader] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP TABLE IF EXISTS [dbo].[RofstHeader] +GO +/****** Object: View [dbo].[vwRofstData_RofstChildren] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstChildren] +GO +/****** Object: View [dbo].[vwRofstData_RofstGroups] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstGroups] +GO +/****** Object: Table [dbo].[RofstDatabase] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP TABLE IF EXISTS [dbo].[RofstDatabase] +GO +/****** Object: Table [dbo].[RofstChild] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP TABLE IF EXISTS [dbo].[RofstChild] +GO +/****** Object: View [dbo].[vwRofstData_RofstDefaultValues] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstDefaultValues] +GO +/****** Object: Table [dbo].[RofstDefaultValue] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP TABLE IF EXISTS [dbo].[RofstDefaultValue] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceVars] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP FUNCTION IF EXISTS [dbo].[vefn_RofstDataReplaceVars] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceApplTagsWithDefaults] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP FUNCTION IF EXISTS [dbo].[vefn_RofstDataReplaceApplTagsWithDefaults] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_NumOfOccurrences] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP FUNCTION IF EXISTS [dbo].[vefn_NumOfOccurrences] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_Clean] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP FUNCTION IF EXISTS [dbo].[vefn_Clean] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_Clean] Script Date: 4/26/2022 6:59:49 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + +If Exists(Select * From sys.objects Where type = 'TF' And object_id = OBJECT_ID('[dbo].[vefn_ParseStringListToTable]')) + Drop Function [dbo].[vefn_ParseStringListToTable]; + + +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 + + + + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 4/21/2022 +-- Description: Cleans (Trim) the string value passed +-- Optional: Truncate is string is passed a specified max length +-- Optional: Convert any null values to an empty string or leave as null +-- ========================================================================================== + +Create Function [dbo].[vefn_Clean] ( @Value VarChar(Max), @ConvertNulls bit = 0, @MaxLength Int = null ) +Returns VarChar(Max) +As +Begin + + Declare @RetVal VarChar(Max); + + If (Len(IsNull(@Value,'')) > 0) + Begin + + Set @RetVal = LTrim(RTrim(@Value)); + If (Not @MaxLength is null And Len(@RetVal) > @MaxLength) Set @RetVal = Left(@RetVal, @MaxLength); + + End + + If (@ConvertNulls = 1) + Set @RetVal = IsNull(@RetVal, ''); + + Return @RetVal; + +End +GO +/****** Object: UserDefinedFunction [dbo].[vefn_NumOfOccurrences] Script Date: 4/26/2022 6:59:49 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_RofstDataReplaceApplTagsWithDefaults] Script Date: 4/26/2022 6:59:49 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 3/25/2022 +-- Description: Replaces any "" tags with the default value +-- ========================================================================================== + +CREATE FUNCTION [dbo].[vefn_RofstDataReplaceApplTagsWithDefaults](@Values VarChar(Max)) Returns VarChar(Max) +WITH EXECUTE AS OWNER +AS +BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @DefaultValue VarChar(Max) = ''; + + Declare @StartTagIndex Int; + Declare @EndTagIndex Int; + Declare @StartTagValue VarChar(Max); + + Set @RetVal = @Values; + Set @StartTagIndex = PatIndex('%%', @RetVal); + + While (@StartTagIndex > 0) + Begin + + Set @StartTagValue = SubString(@RetVal, @StartTagIndex, (@EndTagIndex - @StartTagIndex) + 5); + Set @DefaultValue = Replace(@StartTagValue, '%', @DefaultValue); + + Set @DefaultValue = RTrim(SubString(@DefaultValue, 0, @EndTagIndex)); + Set @RetVal = Replace(@RetVal, @StartTagValue, @DefaultValue); + + Set @StartTagIndex = PatIndex('%%', @RetVal); + + End -- While (@StartTagIndex > 0) + + Return @RetVal; + +END +GO +/****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceVars] Script Date: 4/26/2022 6:59:49 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 3/25/2022 +-- Description: Replaces Any Variables and returns the rest of the value string +-- ========================================================================================== + +CREATE FUNCTION [dbo].[vefn_RofstDataReplaceVars](@Values VarChar(Max)) Returns VarChar(Max) +WITH EXECUTE AS OWNER +AS +BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @EqualsIndex Int; + Declare @EndIndex Int; + Declare @NameValPairStartIndex Int; + Declare @NameValPairEndIndex Int; + + Declare @VarPair VarChar(Max); + Declare @VarName VarChar(Max); + Declare @VarValue VarChar(Max); + + -- Replace Any "" Tags with the Default Value first + Select @RetVal = dbo.vefn_RofstDataReplaceApplTagsWithDefaults(@Values); + + If (PatIndex('%{{A%', @RetVal) > 0) + Set @EndIndex = PatIndex('%{{A%', @RetVal); + Else + Set @EndIndex = Len(@RetVal) -1; + + Set @NameValPairStartIndex = PatIndex('%{%', @RetVal); + Set @NameValPairEndIndex = PatIndex('%}%', @RetVal); + + While(@NameValPairStartIndex > 0 And @NameValPairStartIndex < @EndIndex) + Begin + + -- Get Name Value Pair [ex. {EGS=1214}] + Set @VarPair = SubString(@RetVal, @NameValPairStartIndex, (@NameValPairEndIndex - @NameValPairStartIndex) + 1); + + -- Remove Name Value Pair From Return Val + Set @RetVal = Replace(@RetVal, @VarPair, ''); + + -- Get Variable Name and Value + Set @EqualsIndex = PatIndex('%=%', @VarPair); + + If (@EqualsIndex > 0) + Begin + Set @VarName = SubString(@VarPair, 2, @EqualsIndex - 2); + Set @VarValue = SubString(@VarPair, @EqualsIndex + 1, Len(@VarPair) - @EqualsIndex - 1); + Set @VarName = Concat('{', @VarName, '}'); + + -- Replace All Occurences + Set @RetVal = Replace(@RetVal, @VarName, @VarValue); + End + + -- Get Updated Index Values + If (PatIndex('%{{A%', @RetVal) > 0) + Set @EndIndex = PatIndex('%{{A%', @RetVal); + Else + Set @EndIndex = Len(@RetVal) -1; + + Set @NameValPairStartIndex = PatIndex('%{%', @RetVal); + Set @NameValPairEndIndex = PatIndex('%}%', @RetVal); + + End -- End While(@ReplaceVarEndTagIndex > 0) + + Return @RetVal; + +END +GO +/****** Object: Table [dbo].[RofstDefaultValue] Script Date: 4/26/2022 6:59:49 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[RofstDefaultValue]( + [RofstID] [int] NOT NULL, + [roid] [varchar](50) NOT NULL, + [value] [varchar](max) NOT NULL, + [AccPageID] [varchar](max) NULL, + CONSTRAINT [PK_RofstDefaultValue] PRIMARY KEY CLUSTERED +( + [RofstID] ASC, + [roid] 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_RofstDefaultValues] Script Date: 4/26/2022 6:59:50 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 Rofst Roid Default Values +========================================================================================================== +*/ +Create View [dbo].[vwRofstData_RofstDefaultValues] +As + + Select rdv.RofstID as 'RofstID', + rdv.roid as 'roid', + rdv.[value] as 'value', + rdv.AccPageID as 'AccPageID' + From RofstDefaultValue rdv With (NoLock) + + + +GO +/****** Object: Table [dbo].[RofstChild] Script Date: 4/26/2022 6:59:50 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/26/2022 6:59:50 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_RofstGroups] Script Date: 4/26/2022 6:59:50 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', + -- RoDatabase Info + rd.dbiID as 'dbiID', + rd.dbiType as 'dbiType', + rd.dbiAW as 'dbiAW', + rd.dbiTitle as 'dbiTitle', + rd.dbiAP as 'dbiAP', + -- RoChild Info + 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_RofstChildren] Script Date: 4/26/2022 6:59:50 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', + -- RoDatabase Info + rd.dbiID as 'dbiID', + rd.dbiType as 'dbiType', + rd.dbiAW as 'dbiAW', + rd.dbiTitle as 'dbiTitle', + rd.dbiAP as 'dbiAP', + -- RoChild Info + 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/26/2022 6:59:50 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, + [ROLookup] [varbinary](max) 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] TEXTIMAGE_ON [PRIMARY] +GO +/****** Object: View [dbo].[vwRofstData_RofstHeaders] Script Date: 4/26/2022 6:59:50 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_RofstDatabases] Script Date: 4/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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].[RofstDefaultValue] WITH CHECK ADD CONSTRAINT [FK_RofstDefaultValue_RofstHeader] FOREIGN KEY([RofstID]) +REFERENCES [dbo].[RofstHeader] ([RofstID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[RofstDefaultValue] CHECK CONSTRAINT [FK_RofstDefaultValue_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/26/2022 6:59:50 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 + + Declare @AccPageID VarChar(Max) = null; + Declare @DefaultValues VarChar(Max); + + + -- 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); + + + -- Check for appid, if exists, then insert the default value for each return type if multi-value + If (Len(@appid) > 0) + Begin + + -- Get Accessory Page ID + Select @AccPageID = Concat(d.dbiAP, '-', @appid) + From RofstDatabase d with (NoLock) + Where d.RofstID = @RofstID And d.dbiID = @dbiID; + + -- Insert Rofst Default Value (Parent RoChild) [roid = 12] + Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) + Values (@RofstID, @roid, Replace(@title, '\u160?', ' '), @AccPageID); + + -- Insert Rofst Default Value(s) (Children RoChild) [roid = 16] (Do Not Insert Duplicates) + Select @DefaultValues = Replace(dbo.vefn_RofstDataReplaceVars(@value), '{', ''); + + With ChildrenValues as + ( + Select (x.ListPosition - 1) as 'OffsetIndex', + Case When (PatIndex('%=%', x.ListValue) > 0) Then Right(x.ListValue, Len(x.ListValue)-PatIndex('%=%', x.ListValue)) Else x.ListValue End as 'DefaultValue' + From [dbo].[vefn_ParseStringListToTable](@DefaultValues, '}') x + Where Len(x.ListValue) > 0 + ) + Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) + Select @RofstID as 'RofstID', + Concat(@roid, Cast(Format(Min(OffsetIndex), 'D4') as VarChar(4))) as 'roid', + DefaultValue as 'value', + null as 'AccPageID' + From ChildrenValues + Group By DefaultValue + Order By Min(OffsetIndex) Asc + + End -- (Len(@appid) > 0) + + + Return; + +End +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDatabaseInsert] Script Date: 4/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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_RofstDataGetChildrenByID] Script Date: 4/26/2022 6:59:50 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_RofstDataGetChildrenByID] +( + @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.ParentID = @ID + Order By rc.ID Asc; + + +Return; +End + +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRofstID] Script Date: 4/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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_RofstDataGetValueDifferences] Script Date: 4/26/2022 6:59:50 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_RofstDataGetValueDifferences] +( + @OriginalRofstID Int, + @CurrentRofstID Int +) +With Execute as Owner +As +Begin + + Declare @Differences Table (OriginalRoid VarChar(25), OriginalValue VarChar(Max), + CurrentRoid VarChar(25), CurrentValue VarChar(Max)); + + + With OriginalRofst as + ( + Select rc.roid, rc.[value] + From vwRofstData_RofstChildren rc + Where rc.RofstID = @OriginalRofstID + And Not rc.[value] is null + + ), CurrentRofst as ( + + Select rc.roid, rc.[value] + From vwRofstData_RofstChildren rc + Where rc.RofstID = @CurrentRofstID + And Not rc.[value] is null + ) + Insert Into @Differences (OriginalRoid, OriginalValue, CurrentRoid, CurrentValue) + Select o.roid, o.[value], c.roid, c.[value] + From OriginalRofst o + left outer join CurrentRofst c on c.roid = o.roid + Where o.[value] <> c.[value]; + + + Select OriginalRoid as 'Roid', + Case When (CurrentValue is null) Then 1 Else 0 End as 'IsDeleted', + Case When (Not CurrentValue is null) Then 1 Else 0 End as 'IsModified' + From @Differences; + + +Return; +End + +GO + + + +/****** Object: StoredProcedure [dbo].[vesp_RofstDataSearch] Script Date: 4/26/2022 6:59:50 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: RO Default Value Search + + @SearchTypeID => (1) Starts With (2) Ends With (3) Contains (4) Exact Match +========================================================================================================== + */ +Create Procedure [dbo].[vesp_RofstDataSearch] +( + @RofstID int, + @Value VarChar(Max) = null, + @SearchTypeID Int = 1 -- Starts With +) +With Execute as Owner +As +Begin + + -- Remove any leading/trailing white spaces + Set @Value = dbo.vefn_Clean( @Value, 0, null ); + + -- Escape any % signs in the search value + Set @Value = Replace( @Value, '%', '[%]' ); + + -- Format search value + If (Len(@Value) = 0) Set @Value = null; + + + Select rdv.roid, + rdv.[value] + From vwRofstData_RofstDefaultValues rdv + Where rdv.RofstID = @RofstID + And ((@Value is null) + Or (@SearchTypeID = 1 And rdv.[value] like @Value + '%') -- Starts With + Or (@SearchTypeID = 2 And rdv.[value] like '%' + @Value) -- Ends With + Or (@SearchTypeID = 3 And rdv.[value] like '%' + @Value + '%') -- Contains + Or (@SearchTypeID = 4 And rdv.[value] = @Value)) -- Exact Match + Option (Recompile); + + + +Return; +End + +GO + + + + +/****** Object: StoredProcedure [dbo].[vesp_RofstHeaderInsert] Script Date: 4/26/2022 6:59:50 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, ROLookup, CreateUserID, CreateDate) + Values (@RofstID, @hSize, @hMonth, @hDay, @hcYear, @hcMonth, @hcDay, @hcHour, @hcMin, @hcSec, @hcHund, null, @UserID, GetDate()); + + -- Copy over Binary + Update RofstHeader + Set ROLookup = r.ROLookup + From ROFsts r with (NoLock) + Where r.ROFstID = @RofstID; + + -- Delete from Main ROFsts for now + Update ROFsts + Set ROLookup = null + Where ROFstID = @RofstID; + +Return; +End + +GO + + + + +/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/ +BEGIN TRANSACTION +SET QUOTED_IDENTIFIER ON +SET ARITHABORT ON +SET NUMERIC_ROUNDABORT OFF +SET CONCAT_NULL_YIELDS_NULL ON +SET ANSI_NULLS ON +SET ANSI_PADDING ON +SET ANSI_WARNINGS ON +COMMIT +BEGIN TRANSACTION +GO +ALTER TABLE dbo.ROFsts + DROP CONSTRAINT FK_ROFsts_RODbs +GO +ALTER TABLE dbo.RODbs SET (LOCK_ESCALATION = TABLE) +GO +COMMIT +select Has_Perms_By_Name(N'dbo.RODbs', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.RODbs', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.RODbs', 'Object', 'CONTROL') as Contr_Per BEGIN TRANSACTION +GO +ALTER TABLE dbo.ROFsts + DROP CONSTRAINT DF_Table_1_DTS1 +GO +ALTER TABLE dbo.ROFsts + DROP CONSTRAINT DF_ROFsts_UserID +GO +CREATE TABLE dbo.Tmp_ROFsts + ( + ROFstID int NOT NULL IDENTITY (1, 1), + RODbID int NOT NULL, + ROLookup varbinary(MAX) NULL, + Config nvarchar(MAX) NULL, + DTS datetime NOT NULL, + UserID nvarchar(100) NOT NULL, + LastChanged timestamp NOT NULL + ) ON [PRIMARY] + TEXTIMAGE_ON [PRIMARY] +GO +ALTER TABLE dbo.Tmp_ROFsts SET (LOCK_ESCALATION = TABLE) +GO +DECLARE @v sql_variant +SET @v = N'{datetime}' +EXECUTE sp_addextendedproperty N'MS_Description', @v, N'SCHEMA', N'dbo', N'TABLE', N'Tmp_ROFsts', N'COLUMN', N'DTS' +GO +ALTER TABLE dbo.Tmp_ROFsts ADD CONSTRAINT + DF_Table_1_DTS1 DEFAULT (getdate()) FOR DTS +GO +ALTER TABLE dbo.Tmp_ROFsts ADD CONSTRAINT + DF_ROFsts_UserID DEFAULT (upper(suser_sname())) FOR UserID +GO +SET IDENTITY_INSERT dbo.Tmp_ROFsts ON +GO +IF EXISTS(SELECT * FROM dbo.ROFsts) + EXEC('INSERT INTO dbo.Tmp_ROFsts (ROFstID, RODbID, ROLookup, Config, DTS, UserID) + SELECT ROFstID, RODbID, ROLookup, Config, DTS, UserID FROM dbo.ROFsts WITH (HOLDLOCK TABLOCKX)') +GO +SET IDENTITY_INSERT dbo.Tmp_ROFsts OFF +GO +ALTER TABLE dbo.Figures + DROP CONSTRAINT FK_Figures_ROFsts +GO +ALTER TABLE dbo.Associations + DROP CONSTRAINT FK_Associations_ROFsts +GO +ALTER TABLE dbo.RofstHeader + DROP CONSTRAINT FK_RofstHeader_ROFsts +GO +DROP TABLE dbo.ROFsts +GO +EXECUTE sp_rename N'dbo.Tmp_ROFsts', N'ROFsts', 'OBJECT' +GO +ALTER TABLE dbo.ROFsts ADD CONSTRAINT + PK_ROFsts PRIMARY KEY CLUSTERED + ( + ROFstID + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] + +GO +CREATE UNIQUE NONCLUSTERED INDEX IX_ROFsts ON dbo.ROFsts + ( + RODbID, + DTS + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +GO +ALTER TABLE dbo.ROFsts ADD CONSTRAINT + FK_ROFsts_RODbs FOREIGN KEY + ( + RODbID + ) REFERENCES dbo.RODbs + ( + RODbID + ) ON UPDATE NO ACTION + ON DELETE NO ACTION + +GO +COMMIT +select Has_Perms_By_Name(N'dbo.ROFsts', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.ROFsts', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.ROFsts', 'Object', 'CONTROL') as Contr_Per BEGIN TRANSACTION +GO +ALTER TABLE dbo.RofstHeader ADD CONSTRAINT + FK_RofstHeader_ROFsts FOREIGN KEY + ( + RofstID + ) REFERENCES dbo.ROFsts + ( + ROFstID + ) ON UPDATE NO ACTION + ON DELETE CASCADE + +GO +ALTER TABLE dbo.RofstHeader SET (LOCK_ESCALATION = TABLE) +GO +COMMIT +select Has_Perms_By_Name(N'dbo.RofstHeader', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.RofstHeader', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.RofstHeader', 'Object', 'CONTROL') as Contr_Per BEGIN TRANSACTION +GO +ALTER TABLE dbo.Associations ADD CONSTRAINT + FK_Associations_ROFsts FOREIGN KEY + ( + ROFstID + ) REFERENCES dbo.ROFsts + ( + ROFstID + ) ON UPDATE NO ACTION + ON DELETE NO ACTION + +GO +ALTER TABLE dbo.Associations SET (LOCK_ESCALATION = TABLE) +GO +COMMIT +select Has_Perms_By_Name(N'dbo.Associations', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.Associations', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.Associations', 'Object', 'CONTROL') as Contr_Per BEGIN TRANSACTION +GO +ALTER TABLE dbo.Figures ADD CONSTRAINT + FK_Figures_ROFsts FOREIGN KEY + ( + ROFstID + ) REFERENCES dbo.ROFsts + ( + ROFstID + ) ON UPDATE NO ACTION + ON DELETE NO ACTION + +GO +ALTER TABLE dbo.Figures SET (LOCK_ESCALATION = TABLE) +GO +COMMIT +select Has_Perms_By_Name(N'dbo.Figures', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.Figures', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.Figures', 'Object', 'CONTROL') as Contr_Per diff --git a/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.05.02).sql b/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.05.02).sql new file mode 100644 index 00000000..6b275bdd --- /dev/null +++ b/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.05.02).sql @@ -0,0 +1,1656 @@ + + +/****** Object: StoredProcedure [dbo].[vesp_RofstHeaderInsert] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstHeaderInsert] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataSearch] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataSearch] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetValueDifferences] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetValueDifferences] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetRofstByID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetRofstByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetDatabases] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetDatabases] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetDatabaseByID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetDatabaseByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRoid] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildrenByRoid] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRofstID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildrenByRofstID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildrenByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByRoid] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildByRoid] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildByID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildByAccPageID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildByAccPageID] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataExists] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataExists] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDatabaseInsert] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDatabaseInsert] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstChildInsert] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstChildInsert] +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByType] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP PROCEDURE IF EXISTS [dbo].[vesp_RofstDataGetChildrenByType] +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].[RofstDefaultValue]') AND type in (N'U')) +ALTER TABLE [dbo].[RofstDefaultValue] DROP CONSTRAINT IF EXISTS [FK_RofstDefaultValue_RofstHeader] +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/26/2022 6:59:49 AM ******/ +DROP INDEX IF EXISTS [IX_RofstID_Roid] ON [dbo].[RofstChild] +GO +/****** Object: Index [IX_RofstID_DbiID_ParentID] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP INDEX IF EXISTS [IX_RofstID_DbiID_ParentID] ON [dbo].[RofstChild] +GO +/****** Object: View [dbo].[vwRofstData_RofstDatabases] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstDatabases] +GO +/****** Object: View [dbo].[vwRofstData_RofstHeaders] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstHeaders] +GO +/****** Object: Table [dbo].[RofstHeader] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP TABLE IF EXISTS [dbo].[RofstHeader] +GO +/****** Object: View [dbo].[vwRofstData_RofstChildren] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstChildren] +GO +/****** Object: View [dbo].[vwRofstData_RofstGroups] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstGroups] +GO +/****** Object: Table [dbo].[RofstDatabase] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP TABLE IF EXISTS [dbo].[RofstDatabase] +GO +/****** Object: Table [dbo].[RofstChild] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP TABLE IF EXISTS [dbo].[RofstChild] +GO +/****** Object: View [dbo].[vwRofstData_RofstDefaultValues] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP VIEW IF EXISTS [dbo].[vwRofstData_RofstDefaultValues] +GO +/****** Object: Table [dbo].[RofstDefaultValue] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP TABLE IF EXISTS [dbo].[RofstDefaultValue] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceVars] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP FUNCTION IF EXISTS [dbo].[vefn_RofstDataReplaceVars] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceApplTagsWithDefaults] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP FUNCTION IF EXISTS [dbo].[vefn_RofstDataReplaceApplTagsWithDefaults] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_NumOfOccurrences] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP FUNCTION IF EXISTS [dbo].[vefn_NumOfOccurrences] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_Clean] Script Date: 4/26/2022 6:59:49 AM ******/ +DROP FUNCTION IF EXISTS [dbo].[vefn_Clean] +GO +/****** Object: UserDefinedFunction [dbo].[vefn_Clean] Script Date: 4/26/2022 6:59:49 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + +If Exists(Select * From sys.objects Where type = 'TF' And object_id = OBJECT_ID('[dbo].[vefn_ParseStringListToTable]')) + Drop Function [dbo].[vefn_ParseStringListToTable]; + + +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 + + + + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 4/21/2022 +-- Description: Cleans (Trim) the string value passed +-- Optional: Truncate is string is passed a specified max length +-- Optional: Convert any null values to an empty string or leave as null +-- ========================================================================================== + +Create Function [dbo].[vefn_Clean] ( @Value VarChar(Max), @ConvertNulls bit = 0, @MaxLength Int = null ) +Returns VarChar(Max) +As +Begin + + Declare @RetVal VarChar(Max); + + If (Len(IsNull(@Value,'')) > 0) + Begin + + Set @RetVal = LTrim(RTrim(@Value)); + If (Not @MaxLength is null And Len(@RetVal) > @MaxLength) Set @RetVal = Left(@RetVal, @MaxLength); + + End + + If (@ConvertNulls = 1) + Set @RetVal = IsNull(@RetVal, ''); + + Return @RetVal; + +End +GO +/****** Object: UserDefinedFunction [dbo].[vefn_NumOfOccurrences] Script Date: 4/26/2022 6:59:49 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_RofstDataReplaceApplTagsWithDefaults] Script Date: 4/26/2022 6:59:49 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 3/25/2022 +-- Description: Replaces any "" tags with the default value +-- ========================================================================================== + +CREATE FUNCTION [dbo].[vefn_RofstDataReplaceApplTagsWithDefaults](@Values VarChar(Max)) Returns VarChar(Max) +WITH EXECUTE AS OWNER +AS +BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @DefaultValue VarChar(Max) = ''; + + Declare @StartTagIndex Int; + Declare @EndTagIndex Int; + Declare @StartTagValue VarChar(Max); + + Set @RetVal = @Values; + Set @StartTagIndex = PatIndex('%%', @RetVal); + + While (@StartTagIndex > 0) + Begin + + Set @StartTagValue = SubString(@RetVal, @StartTagIndex, (@EndTagIndex - @StartTagIndex) + 5); + Set @DefaultValue = Replace(@StartTagValue, '%', @DefaultValue); + + Set @DefaultValue = RTrim(SubString(@DefaultValue, 0, @EndTagIndex)); + Set @RetVal = Replace(@RetVal, @StartTagValue, @DefaultValue); + + Set @StartTagIndex = PatIndex('%%', @RetVal); + + End -- While (@StartTagIndex > 0) + + Return @RetVal; + +END +GO +/****** Object: UserDefinedFunction [dbo].[vefn_RofstDataReplaceVars] Script Date: 4/26/2022 6:59:49 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 3/25/2022 +-- Description: Replaces Any Variables and returns the rest of the value string +-- ========================================================================================== + +CREATE FUNCTION [dbo].[vefn_RofstDataReplaceVars](@Values VarChar(Max)) Returns VarChar(Max) +WITH EXECUTE AS OWNER +AS +BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @EqualsIndex Int; + Declare @EndIndex Int; + Declare @NameValPairStartIndex Int; + Declare @NameValPairEndIndex Int; + + Declare @VarPair VarChar(Max); + Declare @VarName VarChar(Max); + Declare @VarValue VarChar(Max); + + -- Replace Any "" Tags with the Default Value first + Select @RetVal = dbo.vefn_RofstDataReplaceApplTagsWithDefaults(@Values); + + If (PatIndex('%{{A%', @RetVal) > 0) + Set @EndIndex = PatIndex('%{{A%', @RetVal); + Else + Set @EndIndex = Len(@RetVal) -1; + + Set @NameValPairStartIndex = PatIndex('%{%', @RetVal); + Set @NameValPairEndIndex = PatIndex('%}%', @RetVal); + + While(@NameValPairStartIndex > 0 And @NameValPairStartIndex < @EndIndex) + Begin + + -- Get Name Value Pair [ex. {EGS=1214}] + Set @VarPair = SubString(@RetVal, @NameValPairStartIndex, (@NameValPairEndIndex - @NameValPairStartIndex) + 1); + + -- Remove Name Value Pair From Return Val + Set @RetVal = Replace(@RetVal, @VarPair, ''); + + -- Get Variable Name and Value + Set @EqualsIndex = PatIndex('%=%', @VarPair); + + If (@EqualsIndex > 0) + Begin + Set @VarName = SubString(@VarPair, 2, @EqualsIndex - 2); + Set @VarValue = SubString(@VarPair, @EqualsIndex + 1, Len(@VarPair) - @EqualsIndex - 1); + Set @VarName = Concat('{', @VarName, '}'); + + -- Replace All Occurences + Set @RetVal = Replace(@RetVal, @VarName, @VarValue); + End + + -- Get Updated Index Values + If (PatIndex('%{{A%', @RetVal) > 0) + Set @EndIndex = PatIndex('%{{A%', @RetVal); + Else + Set @EndIndex = Len(@RetVal) -1; + + Set @NameValPairStartIndex = PatIndex('%{%', @RetVal); + Set @NameValPairEndIndex = PatIndex('%}%', @RetVal); + + End -- End While(@ReplaceVarEndTagIndex > 0) + + Return @RetVal; + +END +GO +/****** Object: Table [dbo].[RofstDefaultValue] Script Date: 4/26/2022 6:59:49 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[RofstDefaultValue]( + [RofstID] [int] NOT NULL, + [roid] [varchar](50) NOT NULL, + [value] [varchar](max) NOT NULL, + [AccPageID] [varchar](max) NULL, + CONSTRAINT [PK_RofstDefaultValue] PRIMARY KEY CLUSTERED +( + [RofstID] ASC, + [roid] 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_RofstDefaultValues] Script Date: 4/26/2022 6:59:50 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 Rofst Roid Default Values +========================================================================================================== +*/ +Create View [dbo].[vwRofstData_RofstDefaultValues] +As + + Select rdv.RofstID as 'RofstID', + rdv.roid as 'roid', + rdv.[value] as 'value', + rdv.AccPageID as 'AccPageID' + From RofstDefaultValue rdv With (NoLock) + + + +GO +/****** Object: Table [dbo].[RofstChild] Script Date: 4/26/2022 6:59:50 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/26/2022 6:59:50 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_RofstGroups] Script Date: 4/26/2022 6:59:50 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', + -- RoDatabase Info + rd.dbiID as 'dbiID', + rd.dbiType as 'dbiType', + rd.dbiAW as 'dbiAW', + rd.dbiTitle as 'dbiTitle', + rd.dbiAP as 'dbiAP', + -- RoChild Info + 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_RofstChildren] Script Date: 4/26/2022 6:59:50 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', + -- RoDatabase Info + rd.dbiID as 'dbiID', + rd.dbiType as 'dbiType', + rd.dbiAW as 'dbiAW', + rd.dbiTitle as 'dbiTitle', + rd.dbiAP as 'dbiAP', + -- RoChild Info + rc.ID as 'ID', + rc.ParentID as 'ParentID', + rc.[type] as 'type', + Case When (rc.[type] = 1) Then 'Single Line Text' -- Fixed Length Text + When (rc.[type] = 2) Then 'Table' + When (rc.[type] = 3) Then 'Multiple Line Text' + When (rc.[type] = 4) Then 'X/Y Plot' + When (rc.[type] = 8) Then 'Image' + Else 'Unknown' End as 'TypeDescription', + 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/26/2022 6:59:50 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, + [ROLookup] [varbinary](max) 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] TEXTIMAGE_ON [PRIMARY] +GO +/****** Object: View [dbo].[vwRofstData_RofstHeaders] Script Date: 4/26/2022 6:59:50 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_RofstDatabases] Script Date: 4/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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].[RofstDefaultValue] WITH CHECK ADD CONSTRAINT [FK_RofstDefaultValue_RofstHeader] FOREIGN KEY([RofstID]) +REFERENCES [dbo].[RofstHeader] ([RofstID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[RofstDefaultValue] CHECK CONSTRAINT [FK_RofstDefaultValue_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/26/2022 6:59:50 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 + + Declare @AccPageID VarChar(Max) = null; + Declare @DefaultValues VarChar(Max); + + + -- 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); + + + -- Check for appid, if exists, then insert the default value for each return type if multi-value + If (Len(@appid) > 0) + Begin + + -- Get Accessory Page ID + Select @AccPageID = Concat(d.dbiAP, '-', @appid) + From RofstDatabase d with (NoLock) + Where d.RofstID = @RofstID And d.dbiID = @dbiID; + + -- Insert Rofst Default Value (Parent RoChild) [roid = 12] + Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) + Values (@RofstID, @roid, Replace(@title, '\u160?', ' '), @AccPageID); + + -- Insert Rofst Default Value(s) (Children RoChild) [roid = 16] (Do Not Insert Duplicates) + Select @DefaultValues = Replace(dbo.vefn_RofstDataReplaceVars(@value), '{', ''); + + With ChildrenValues as + ( + Select (x.ListPosition - 1) as 'OffsetIndex', + Case When (PatIndex('%=%', x.ListValue) > 0) Then Right(x.ListValue, Len(x.ListValue)-PatIndex('%=%', x.ListValue)) Else x.ListValue End as 'DefaultValue' + From [dbo].[vefn_ParseStringListToTable](@DefaultValues, '}') x + Where Len(x.ListValue) > 0 + ) + Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) + Select @RofstID as 'RofstID', + Concat(@roid, Cast(Format(Min(OffsetIndex), 'D4') as VarChar(4))) as 'roid', + DefaultValue as 'value', + null as 'AccPageID' + From ChildrenValues + Group By DefaultValue + Order By Min(OffsetIndex) Asc + + End -- (Len(@appid) > 0) + + + Return; + +End +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDatabaseInsert] Script Date: 4/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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_RofstDataGetChildrenByID] Script Date: 4/26/2022 6:59:50 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_RofstDataGetChildrenByID] +( + @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.ParentID = @ID + Order By rc.ID Asc; + + +Return; +End + +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByRofstID] Script Date: 4/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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/26/2022 6:59:50 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 IsNull(r.ROLookup, rh.ROLookup) Else null End as 'ROLookup', + r.DTS, + r.UserID, + r.LastChanged + From ROFsts r with (NoLock) + left outer join RofstHeader rh with (NoLock) on rh.RofstID = r.ROFstID + Where r.RofstID = @RofstID; + + +Return; +End + +GO +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetValueDifferences] Script Date: 4/26/2022 6:59:50 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_RofstDataGetValueDifferences] +( + @OriginalRofstID Int, + @CurrentRofstID Int +) +With Execute as Owner +As +Begin + + Declare @Differences Table (OriginalRoid VarChar(25), OriginalValue VarChar(Max), + CurrentRoid VarChar(25), CurrentValue VarChar(Max)); + + + With OriginalRofst as + ( + Select rc.roid, rc.[value] + From vwRofstData_RofstChildren rc + Where rc.RofstID = @OriginalRofstID + And Not rc.[value] is null + + ), CurrentRofst as ( + + Select rc.roid, rc.[value] + From vwRofstData_RofstChildren rc + Where rc.RofstID = @CurrentRofstID + And Not rc.[value] is null + ) + Insert Into @Differences (OriginalRoid, OriginalValue, CurrentRoid, CurrentValue) + Select o.roid, o.[value], c.roid, c.[value] + From OriginalRofst o + left outer join CurrentRofst c on c.roid = o.roid + Where o.[value] <> c.[value]; + + + Select OriginalRoid as 'Roid', + Case When (CurrentValue is null) Then 1 Else 0 End as 'IsDeleted', + Case When (Not CurrentValue is null) Then 1 Else 0 End as 'IsModified' + From @Differences; + + +Return; +End + +GO + + + +/****** Object: StoredProcedure [dbo].[vesp_RofstDataSearch] Script Date: 4/26/2022 6:59:50 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: RO Default Value Search + + @SearchTypeID => (1) Starts With (2) Ends With (3) Contains (4) Exact Match +========================================================================================================== + */ +Create Procedure [dbo].[vesp_RofstDataSearch] +( + @RofstID int, + @Value VarChar(Max) = null, + @SearchTypeID Int = 1 -- Starts With +) +With Execute as Owner +As +Begin + + -- Remove any leading/trailing white spaces + Set @Value = dbo.vefn_Clean( @Value, 0, null ); + + -- Escape any % signs in the search value + Set @Value = Replace( @Value, '%', '[%]' ); + + -- Format search value + If (Len(@Value) = 0) Set @Value = null; + + + Select rdv.roid, + rdv.[value] + From vwRofstData_RofstDefaultValues rdv + Where rdv.RofstID = @RofstID + And ((@Value is null) + Or (@SearchTypeID = 1 And rdv.[value] like @Value + '%') -- Starts With + Or (@SearchTypeID = 2 And rdv.[value] like '%' + @Value) -- Ends With + Or (@SearchTypeID = 3 And rdv.[value] like '%' + @Value + '%') -- Contains + Or (@SearchTypeID = 4 And rdv.[value] = @Value)) -- Exact Match + Order By rdv.[value] Asc, rdv.roid Asc + Option (Recompile); + + + +Return; +End + +GO + + + +/****** Object: StoredProcedure [dbo].[vesp_RofstDataGetChildrenByType] Script Date: 4/26/2022 6:59:50 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_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 + + + + + +/****** Object: StoredProcedure [dbo].[vesp_RofstHeaderInsert] Script Date: 4/26/2022 6:59:50 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, ROLookup, CreateUserID, CreateDate) + Values (@RofstID, @hSize, @hMonth, @hDay, @hcYear, @hcMonth, @hcDay, @hcHour, @hcMin, @hcSec, @hcHund, null, @UserID, GetDate()); + + -- Copy over Binary + Update RofstHeader + Set ROLookup = r.ROLookup + From ROFsts r with (NoLock) + Where r.ROFstID = @RofstID; + + -- Delete from Main ROFsts for now + Update ROFsts + Set ROLookup = null + Where ROFstID = @RofstID; + +Return; +End + +GO + + + + +/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/ +BEGIN TRANSACTION +SET QUOTED_IDENTIFIER ON +SET ARITHABORT ON +SET NUMERIC_ROUNDABORT OFF +SET CONCAT_NULL_YIELDS_NULL ON +SET ANSI_NULLS ON +SET ANSI_PADDING ON +SET ANSI_WARNINGS ON +COMMIT +BEGIN TRANSACTION +GO +ALTER TABLE dbo.ROFsts + DROP CONSTRAINT FK_ROFsts_RODbs +GO +ALTER TABLE dbo.RODbs SET (LOCK_ESCALATION = TABLE) +GO +COMMIT +select Has_Perms_By_Name(N'dbo.RODbs', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.RODbs', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.RODbs', 'Object', 'CONTROL') as Contr_Per BEGIN TRANSACTION +GO +ALTER TABLE dbo.ROFsts + DROP CONSTRAINT DF_Table_1_DTS1 +GO +ALTER TABLE dbo.ROFsts + DROP CONSTRAINT DF_ROFsts_UserID +GO +CREATE TABLE dbo.Tmp_ROFsts + ( + ROFstID int NOT NULL IDENTITY (1, 1), + RODbID int NOT NULL, + ROLookup varbinary(MAX) NULL, + Config nvarchar(MAX) NULL, + DTS datetime NOT NULL, + UserID nvarchar(100) NOT NULL, + LastChanged timestamp NOT NULL + ) ON [PRIMARY] + TEXTIMAGE_ON [PRIMARY] +GO +ALTER TABLE dbo.Tmp_ROFsts SET (LOCK_ESCALATION = TABLE) +GO +DECLARE @v sql_variant +SET @v = N'{datetime}' +EXECUTE sp_addextendedproperty N'MS_Description', @v, N'SCHEMA', N'dbo', N'TABLE', N'Tmp_ROFsts', N'COLUMN', N'DTS' +GO +ALTER TABLE dbo.Tmp_ROFsts ADD CONSTRAINT + DF_Table_1_DTS1 DEFAULT (getdate()) FOR DTS +GO +ALTER TABLE dbo.Tmp_ROFsts ADD CONSTRAINT + DF_ROFsts_UserID DEFAULT (upper(suser_sname())) FOR UserID +GO +SET IDENTITY_INSERT dbo.Tmp_ROFsts ON +GO +IF EXISTS(SELECT * FROM dbo.ROFsts) + EXEC('INSERT INTO dbo.Tmp_ROFsts (ROFstID, RODbID, ROLookup, Config, DTS, UserID) + SELECT ROFstID, RODbID, ROLookup, Config, DTS, UserID FROM dbo.ROFsts WITH (HOLDLOCK TABLOCKX)') +GO +SET IDENTITY_INSERT dbo.Tmp_ROFsts OFF +GO +ALTER TABLE dbo.Figures + DROP CONSTRAINT FK_Figures_ROFsts +GO +ALTER TABLE dbo.Associations + DROP CONSTRAINT FK_Associations_ROFsts +GO +ALTER TABLE dbo.RofstHeader + DROP CONSTRAINT FK_RofstHeader_ROFsts +GO +DROP TABLE dbo.ROFsts +GO +EXECUTE sp_rename N'dbo.Tmp_ROFsts', N'ROFsts', 'OBJECT' +GO +ALTER TABLE dbo.ROFsts ADD CONSTRAINT + PK_ROFsts PRIMARY KEY CLUSTERED + ( + ROFstID + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] + +GO +CREATE UNIQUE NONCLUSTERED INDEX IX_ROFsts ON dbo.ROFsts + ( + RODbID, + DTS + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +GO +ALTER TABLE dbo.ROFsts ADD CONSTRAINT + FK_ROFsts_RODbs FOREIGN KEY + ( + RODbID + ) REFERENCES dbo.RODbs + ( + RODbID + ) ON UPDATE NO ACTION + ON DELETE NO ACTION + +GO +COMMIT +select Has_Perms_By_Name(N'dbo.ROFsts', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.ROFsts', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.ROFsts', 'Object', 'CONTROL') as Contr_Per BEGIN TRANSACTION +GO +ALTER TABLE dbo.RofstHeader ADD CONSTRAINT + FK_RofstHeader_ROFsts FOREIGN KEY + ( + RofstID + ) REFERENCES dbo.ROFsts + ( + ROFstID + ) ON UPDATE NO ACTION + ON DELETE CASCADE + +GO +ALTER TABLE dbo.RofstHeader SET (LOCK_ESCALATION = TABLE) +GO +COMMIT +select Has_Perms_By_Name(N'dbo.RofstHeader', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.RofstHeader', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.RofstHeader', 'Object', 'CONTROL') as Contr_Per BEGIN TRANSACTION +GO +ALTER TABLE dbo.Associations ADD CONSTRAINT + FK_Associations_ROFsts FOREIGN KEY + ( + ROFstID + ) REFERENCES dbo.ROFsts + ( + ROFstID + ) ON UPDATE NO ACTION + ON DELETE NO ACTION + +GO +ALTER TABLE dbo.Associations SET (LOCK_ESCALATION = TABLE) +GO +COMMIT +select Has_Perms_By_Name(N'dbo.Associations', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.Associations', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.Associations', 'Object', 'CONTROL') as Contr_Per BEGIN TRANSACTION +GO +ALTER TABLE dbo.Figures ADD CONSTRAINT + FK_Figures_ROFsts FOREIGN KEY + ( + ROFstID + ) REFERENCES dbo.ROFsts + ( + ROFstID + ) ON UPDATE NO ACTION + ON DELETE NO ACTION + +GO +ALTER TABLE dbo.Figures SET (LOCK_ESCALATION = TABLE) +GO +COMMIT +select Has_Perms_By_Name(N'dbo.Figures', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.Figures', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.Figures', 'Object', 'CONTROL') as Contr_Per diff --git a/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.05.11).sql b/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.05.11).sql new file mode 100644 index 00000000..7e59d650 --- /dev/null +++ b/PROMS/SQL Data Tools/RO Memory/script_DeployRofstData (2022.05.11).sql @@ -0,0 +1,1512 @@ + + +IF Not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RofstHeader]') AND type in (N'U')) +Begin + + /****** Object: Table [dbo].[RofstDefaultValue] Script Date: 4/26/2022 6:59:49 AM ******/ + SET ANSI_NULLS ON + + SET QUOTED_IDENTIFIER ON + + CREATE TABLE [dbo].[RofstDefaultValue]( + [RofstID] [int] NOT NULL, + [roid] [varchar](50) NOT NULL, + [value] [varchar](max) NOT NULL, + [AccPageID] [varchar](max) NULL, + CONSTRAINT [PK_RofstDefaultValue] PRIMARY KEY CLUSTERED + ( + [RofstID] ASC, + [roid] 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] + + + /****** Object: Table [dbo].[RofstChild] Script Date: 4/26/2022 6:59:50 AM ******/ + SET ANSI_NULLS ON + + SET QUOTED_IDENTIFIER ON + + 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] + + /****** Object: Table [dbo].[RofstDatabase] Script Date: 4/26/2022 6:59:50 AM ******/ + SET ANSI_NULLS ON + + SET QUOTED_IDENTIFIER ON + + 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] + + + /****** Object: Table [dbo].[RofstHeader] Script Date: 4/26/2022 6:59:50 AM ******/ + SET ANSI_NULLS ON + + SET QUOTED_IDENTIFIER ON + + 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] + + + /****** Object: Index [IX_RofstID_DbiID_ParentID] Script Date: 4/26/2022 6:59:50 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] + + SET ANSI_PADDING ON + + /****** Object: Index [IX_RofstID_Roid] Script Date: 4/26/2022 6:59:50 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] + + ALTER TABLE [dbo].[RofstDatabase] ADD CONSTRAINT [DF_RofstDatabase_ParentID] DEFAULT ((0)) FOR [ParentID] + + ALTER TABLE [dbo].[RofstHeader] ADD CONSTRAINT [DF_RofstHeader_CreateUserID] DEFAULT ('SYSTEM') FOR [CreateUserID] + + ALTER TABLE [dbo].[RofstHeader] ADD CONSTRAINT [DF_RofstHeader_CreateDate] DEFAULT (getdate()) FOR [CreateDate] + + ALTER TABLE [dbo].[RofstChild] WITH CHECK ADD CONSTRAINT [FK_RofstChild_RofstDatabase] FOREIGN KEY([RofstID], [dbiID]) + REFERENCES [dbo].[RofstDatabase] ([RofstID], [dbiID]) + ON DELETE CASCADE + + ALTER TABLE [dbo].[RofstChild] CHECK CONSTRAINT [FK_RofstChild_RofstDatabase] + + ALTER TABLE [dbo].[RofstDatabase] WITH CHECK ADD CONSTRAINT [FK_RofstDatabase_RofstHeader] FOREIGN KEY([RofstID]) + REFERENCES [dbo].[RofstHeader] ([RofstID]) + ON DELETE CASCADE + + ALTER TABLE [dbo].[RofstDatabase] CHECK CONSTRAINT [FK_RofstDatabase_RofstHeader] + + ALTER TABLE [dbo].[RofstDefaultValue] WITH CHECK ADD CONSTRAINT [FK_RofstDefaultValue_RofstHeader] FOREIGN KEY([RofstID]) + REFERENCES [dbo].[RofstHeader] ([RofstID]) + ON DELETE CASCADE + + ALTER TABLE [dbo].[RofstDefaultValue] CHECK CONSTRAINT [FK_RofstDefaultValue_RofstHeader] + + ALTER TABLE [dbo].[RofstHeader] WITH CHECK ADD CONSTRAINT [FK_RofstHeader_ROFsts] FOREIGN KEY([RofstID]) + REFERENCES [dbo].[ROFsts] ([ROFstID]) + ON DELETE CASCADE + + ALTER TABLE [dbo].[RofstHeader] CHECK CONSTRAINT [FK_RofstHeader_ROFsts] + +End +Go + + + + + +If Exists(Select * From sys.objects Where type = 'FN' And object_id = OBJECT_ID('[dbo].[vefn_Clean]')) + Drop Function [dbo].[vefn_Clean]; + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 4/21/2022 +-- Description: Cleans (Trim) the string value passed +-- Optional: Truncate is string is passed a specified max length +-- Optional: Convert any null values to an empty string or leave as null +-- ========================================================================================== + +Create Function [dbo].[vefn_Clean] ( @Value VarChar(Max), @ConvertNulls bit = 0, @MaxLength Int = null ) +Returns VarChar(Max) +As +Begin + + Declare @RetVal VarChar(Max); + + If (Len(IsNull(@Value,'')) > 0) + Begin + + Set @RetVal = LTrim(RTrim(@Value)); + If (Not @MaxLength is null And Len(@RetVal) > @MaxLength) Set @RetVal = Left(@RetVal, @MaxLength); + + End + + If (@ConvertNulls = 1) + Set @RetVal = IsNull(@RetVal, ''); + + Return @RetVal; + +End +GO + + + +If Exists(Select * From sys.objects Where type = 'TF' And object_id = OBJECT_ID('[dbo].[vefn_ParseStringListToTable]')) + Drop Function [dbo].[vefn_ParseStringListToTable]; + + +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 + + + + + +If Exists(Select * From sys.objects Where type = 'FN' And object_id = OBJECT_ID('[dbo].[vefn_NumOfOccurrences]')) + Drop Function [dbo].[vefn_NumOfOccurrences]; + + + +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 + + + + + +If Exists(Select * From sys.objects Where type = 'FN' And object_id = OBJECT_ID('[dbo].[vefn_RofstDataReplaceApplTagsWithDefaults]')) + Drop Function [dbo].[vefn_RofstDataReplaceApplTagsWithDefaults]; + + + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 3/25/2022 +-- Description: Replaces any "" tags with the default value +-- ========================================================================================== + +CREATE FUNCTION [dbo].[vefn_RofstDataReplaceApplTagsWithDefaults](@Values VarChar(Max)) Returns VarChar(Max) +WITH EXECUTE AS OWNER +AS +BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @DefaultValue VarChar(Max) = ''; + + Declare @StartTagIndex Int; + Declare @EndTagIndex Int; + Declare @StartTagValue VarChar(Max); + + Set @RetVal = @Values; + Set @StartTagIndex = PatIndex('%%', @RetVal); + + While (@StartTagIndex > 0) + Begin + + Set @StartTagValue = SubString(@RetVal, @StartTagIndex, (@EndTagIndex - @StartTagIndex) + 5); + Set @DefaultValue = Replace(@StartTagValue, '%', @DefaultValue); + + Set @DefaultValue = RTrim(SubString(@DefaultValue, 0, @EndTagIndex)); + Set @RetVal = Replace(@RetVal, @StartTagValue, @DefaultValue); + + Set @StartTagIndex = PatIndex('%%', @RetVal); + + End -- While (@StartTagIndex > 0) + + Return @RetVal; + +END +Go + + +If Exists(Select * From sys.objects Where type = 'FN' And object_id = OBJECT_ID('[dbo].[vefn_RofstDataReplaceVars]')) + Drop Function [dbo].[vefn_RofstDataReplaceVars]; + + + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 3/25/2022 +-- Description: Replaces Any Variables and returns the rest of the value string +-- ========================================================================================== + +CREATE FUNCTION [dbo].[vefn_RofstDataReplaceVars](@Values VarChar(Max)) Returns VarChar(Max) +WITH EXECUTE AS OWNER +AS +BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @EqualsIndex Int; + Declare @EndIndex Int; + Declare @NameValPairStartIndex Int; + Declare @NameValPairEndIndex Int; + + Declare @VarPair VarChar(Max); + Declare @VarName VarChar(Max); + Declare @VarValue VarChar(Max); + + -- Replace Any "" Tags with the Default Value first + Select @RetVal = dbo.vefn_RofstDataReplaceApplTagsWithDefaults(@Values); + + If (PatIndex('%{{A%', @RetVal) > 0) + Set @EndIndex = PatIndex('%{{A%', @RetVal); + Else + Set @EndIndex = Len(@RetVal) -1; + + Set @NameValPairStartIndex = PatIndex('%{%', @RetVal); + Set @NameValPairEndIndex = PatIndex('%}%', @RetVal); + + While(@NameValPairStartIndex > 0 And @NameValPairStartIndex < @EndIndex) + Begin + + -- Get Name Value Pair [ex. {EGS=1214}] + Set @VarPair = SubString(@RetVal, @NameValPairStartIndex, (@NameValPairEndIndex - @NameValPairStartIndex) + 1); + + -- Remove Name Value Pair From Return Val + Set @RetVal = Replace(@RetVal, @VarPair, ''); + + -- Get Variable Name and Value + Set @EqualsIndex = PatIndex('%=%', @VarPair); + + If (@EqualsIndex > 0) + Begin + Set @VarName = SubString(@VarPair, 2, @EqualsIndex - 2); + Set @VarValue = SubString(@VarPair, @EqualsIndex + 1, Len(@VarPair) - @EqualsIndex - 1); + Set @VarName = Concat('{', @VarName, '}'); + + -- Replace All Occurences + Set @RetVal = Replace(@RetVal, @VarName, @VarValue); + End + + -- Get Updated Index Values + If (PatIndex('%{{A%', @RetVal) > 0) + Set @EndIndex = PatIndex('%{{A%', @RetVal); + Else + Set @EndIndex = Len(@RetVal) -1; + + Set @NameValPairStartIndex = PatIndex('%{%', @RetVal); + Set @NameValPairEndIndex = PatIndex('%}%', @RetVal); + + End -- End While(@ReplaceVarEndTagIndex > 0) + + Return @RetVal; + +END +Go + + + + +If Exists(Select * From sys.views Where Name = N'vwRofstData_RofstDefaultValues') + Drop View [dbo].[vwRofstData_RofstDefaultValues]; +Go + +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 Rofst Roid Default Values +========================================================================================================== +*/ +Create View [dbo].[vwRofstData_RofstDefaultValues] +As + + Select rdv.RofstID as 'RofstID', + rdv.roid as 'roid', + rdv.[value] as 'value', + rdv.AccPageID as 'AccPageID' + From RofstDefaultValue rdv With (NoLock) + + + +GO + + + + + +If Exists(Select * From sys.views Where Name = N'vwRofstData_RofstHeaders') + Drop View [dbo].[vwRofstData_RofstHeaders]; +Go + +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 + + + + +If Exists(Select * From sys.views Where Name = N'vwRofstData_RofstDatabases') + Drop View [dbo].[vwRofstData_RofstDatabases]; +Go + +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 + + +If Exists(Select * From sys.views Where Name = N'vwRofstData_RofstChildren') + Drop View [dbo].[vwRofstData_RofstChildren]; +Go + +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', + -- RoDatabase Info + rd.dbiID as 'dbiID', + rd.dbiType as 'dbiType', + rd.dbiAW as 'dbiAW', + rd.dbiTitle as 'dbiTitle', + rd.dbiAP as 'dbiAP', + -- RoChild Info + rc.ID as 'ID', + rc.ParentID as 'ParentID', + rc.[type] as 'type', + Case When (rc.[type] = 1) Then 'Single Line Text' -- Fixed Length Text + When (rc.[type] = 2) Then 'Table' + When (rc.[type] = 3) Then 'Multiple Line Text' + When (rc.[type] = 4) Then 'X/Y Plot' + When (rc.[type] = 8) Then 'Image' + Else 'Unknown' End as 'TypeDescription', + 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 + + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstChildInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstChildInsert]; +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_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 + + Declare @AccPageID VarChar(Max) = null; + Declare @DefaultValues VarChar(Max); + + + -- 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); + + + -- Check for appid, if exists, then insert the default value for each return type if multi-value + If (Len(@appid) > 0) + Begin + + -- Get Accessory Page ID + Select @AccPageID = Concat(d.dbiAP, '-', @appid) + From RofstDatabase d with (NoLock) + Where d.RofstID = @RofstID And d.dbiID = @dbiID; + + -- Insert Rofst Default Value (Parent RoChild) [roid = 12] + Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) + Values (@RofstID, @roid, Replace(@title, '\u160?', ' '), @AccPageID); + + -- Insert Rofst Default Value(s) (Children RoChild) [roid = 16] (Do Not Insert Duplicates) + Select @DefaultValues = Replace(dbo.vefn_RofstDataReplaceVars(@value), '{', ''); + + With ChildrenValues as + ( + Select (x.ListPosition - 1) as 'OffsetIndex', + Case When (PatIndex('%=%', x.ListValue) > 0) Then Right(x.ListValue, Len(x.ListValue)-PatIndex('%=%', x.ListValue)) Else x.ListValue End as 'DefaultValue' + From [dbo].[vefn_ParseStringListToTable](@DefaultValues, '}') x + Where Len(x.ListValue) > 0 + ) + Insert Into RofstDefaultValue (RofstID, roid, [value], AccPageID) + Select @RofstID as 'RofstID', + Concat(@roid, Cast(Format(Min(OffsetIndex), 'D4') as VarChar(4))) as 'roid', + DefaultValue as 'value', + null as 'AccPageID' + From ChildrenValues + Group By DefaultValue + Order By Min(OffsetIndex) Asc + + End -- (Len(@appid) > 0) + + + Return; + +End +Go + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDatabaseInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDatabaseInsert]; +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_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 + + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataExists]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataExists]; +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_RofstDataExists] +( + @RofstID int +) +With Execute as Owner +As +Begin + + Select Count(1) + From RofstHeader with (NoLock) + Where RofstID = @RofstID; + + +Return; +End + +GO + + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildByAccPageID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetChildByAccPageID]; +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_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 + + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildByID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetChildByID]; +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_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 + + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildByRoid]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetChildByRoid]; +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_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 + + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildrenByID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetChildrenByID]; +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_RofstDataGetChildrenByID] +( + @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.ParentID = @ID + Order By rc.ID Asc; + + +Return; +End + +GO + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildrenByRofstID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetChildrenByRofstID]; +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_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 + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildrenByRoid]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetChildrenByRoid]; +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_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 + + +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 + + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetDatabaseByID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetDatabaseByID]; +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_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 + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetDatabases]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetDatabases]; +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_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 + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetRofstByID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetRofstByID]; +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_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 + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetValueDifferences]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetValueDifferences]; +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_RofstDataGetValueDifferences] +( + @OriginalRofstID Int, + @CurrentRofstID Int +) +With Execute as Owner +As +Begin + + Declare @Differences Table (OriginalRoid VarChar(25), OriginalValue VarChar(Max), + CurrentRoid VarChar(25), CurrentValue VarChar(Max)); + + + With OriginalRofst as + ( + Select rc.roid, rc.[value] + From vwRofstData_RofstChildren rc + Where rc.RofstID = @OriginalRofstID + And Not rc.[value] is null + + ), CurrentRofst as ( + + Select rc.roid, rc.[value] + From vwRofstData_RofstChildren rc + Where rc.RofstID = @CurrentRofstID + And Not rc.[value] is null + ) + Insert Into @Differences (OriginalRoid, OriginalValue, CurrentRoid, CurrentValue) + Select o.roid, o.[value], c.roid, c.[value] + From OriginalRofst o + left outer join CurrentRofst c on c.roid = o.roid + Where o.[value] <> c.[value]; + + + Select OriginalRoid as 'Roid', + Case When (CurrentValue is null) Then 1 Else 0 End as 'IsDeleted', + Case When (Not CurrentValue is null) Then 1 Else 0 End as 'IsModified' + From @Differences; + + +Return; +End + +GO + + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataSearch]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataSearch]; +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: RO Default Value Search + + @SearchTypeID => (1) Starts With (2) Ends With (3) Contains (4) Exact Match +========================================================================================================== + */ +Create Procedure [dbo].[vesp_RofstDataSearch] +( + @RofstID int, + @Value VarChar(Max) = null, + @SearchTypeID Int = 1, -- Starts With + @MaxNumOfRecords Int = null +) +With Execute as Owner +As +Begin + + -- Remove any leading/trailing white spaces + Set @Value = dbo.vefn_Clean( @Value, 0, null ); + + -- Escape any % signs in the search value + Set @Value = Replace( @Value, '%', '[%]' ); + + -- Format search value + If (Len(@Value) = 0) Set @Value = null; + + -- Create Temp Results Table + Create Table #SearchResults + (roid VarChar(50) Not Null, [value] VarChar(Max), RowNum Int Not Null Primary Key); + + -- Select roids/values based on search criteria + Insert Into #SearchResults (roid, [value], RowNum) + Select rdv.roid, + rdv.[value], + Row_Number() Over (Order By rdv.[value] Asc, rdv.roid Asc) as 'RowNum' + From vwRofstData_RofstDefaultValues rdv + Where rdv.RofstID = @RofstID + And ((@Value is null) + Or (@SearchTypeID = 1 And rdv.[value] like @Value + '%') -- Starts With + Or (@SearchTypeID = 2 And rdv.[value] like '%' + @Value) -- Ends With + Or (@SearchTypeID = 3 And rdv.[value] like '%' + @Value + '%') -- Contains + Or (@SearchTypeID = 4 And rdv.[value] = @Value)) -- Exact Match + Order By rdv.[value] Asc, rdv.roid Asc + Option (Recompile); + + -- Return the specified number of results + Select sr.roid, sr.[value] + From #SearchResults sr + Where (@MaxNumOfRecords is null Or sr.RowNum <= @MaxNumOfRecords) + Order By sr.RowNum Asc; + + + +Return; +End + +GO + + + + + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstHeaderInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstHeaderInsert]; +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_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 + + + + + + + + + + + + + + diff --git a/PROMS/SQL Data Tools/RO Memory/script_RollbackRofstData (2022.05.11).sql b/PROMS/SQL Data Tools/RO Memory/script_RollbackRofstData (2022.05.11).sql new file mode 100644 index 00000000..4bf0eefe --- /dev/null +++ b/PROMS/SQL Data Tools/RO Memory/script_RollbackRofstData (2022.05.11).sql @@ -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 + + + + diff --git a/PROMS/SQL Data Tools/RO Memory/vesp_RofstDataGetChildrenByType.sql b/PROMS/SQL Data Tools/RO Memory/vesp_RofstDataGetChildrenByType.sql new file mode 100644 index 00000000..18accd4d --- /dev/null +++ b/PROMS/SQL Data Tools/RO Memory/vesp_RofstDataGetChildrenByType.sql @@ -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 + + diff --git a/PROMS/SQL Data Tools/ROCleanUp.sql b/PROMS/SQL Data Tools/ROCleanUp.sql new file mode 100644 index 00000000..a28d1cfc --- /dev/null +++ b/PROMS/SQL Data Tools/ROCleanUp.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/RODBS.sql b/PROMS/SQL Data Tools/RODBS.sql new file mode 100644 index 00000000..d11fbe9f --- /dev/null +++ b/PROMS/SQL Data Tools/RODBS.sql @@ -0,0 +1 @@ +select * from rodbs \ No newline at end of file diff --git a/PROMS/SQL Data Tools/RODatabaseUsage.sql b/PROMS/SQL Data Tools/RODatabaseUsage.sql new file mode 100644 index 00000000..e1283f34 --- /dev/null +++ b/PROMS/SQL Data Tools/RODatabaseUsage.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/ROFstsSize.sql b/PROMS/SQL Data Tools/ROFstsSize.sql new file mode 100644 index 00000000..e9c2426f --- /dev/null +++ b/PROMS/SQL Data Tools/ROFstsSize.sql @@ -0,0 +1 @@ +select ROFSTID,RODBID,Len(ROLOOKUP) MyLength, DTS,UserID from ROFSTS \ No newline at end of file diff --git a/PROMS/SQL Data Tools/ROValues.sql b/PROMS/SQL Data Tools/ROValues.sql new file mode 100644 index 00000000..f3a3f78c --- /dev/null +++ b/PROMS/SQL Data Tools/ROValues.sql @@ -0,0 +1,81 @@ +/* +DECLARE @TEXT nvarchar(max) +select @TEXT = TEXT from Contents where ContentID Like 17259 +select * from vefn_SplitROs(@TEXT) +--\v \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 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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/RemoveFolder.sql b/PROMS/SQL Data Tools/RemoveFolder.sql new file mode 100644 index 00000000..a39fe292 --- /dev/null +++ b/PROMS/SQL Data Tools/RemoveFolder.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/RemoveParentFolder.sql b/PROMS/SQL Data Tools/RemoveParentFolder.sql new file mode 100644 index 00000000..34ef815b --- /dev/null +++ b/PROMS/SQL Data Tools/RemoveParentFolder.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/RemoveUneditableStepText.sql b/PROMS/SQL Data Tools/RemoveUneditableStepText.sql new file mode 100644 index 00000000..babec212 --- /dev/null +++ b/PROMS/SQL Data Tools/RemoveUneditableStepText.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/ReplaceSquaresWithDashesInTables.sql b/PROMS/SQL Data Tools/ReplaceSquaresWithDashesInTables.sql new file mode 100644 index 00000000..371e8b03 --- /dev/null +++ b/PROMS/SQL Data Tools/ReplaceSquaresWithDashesInTables.sql @@ -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;}%' \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Search for all RNOs in a database.sql b/PROMS/SQL Data Tools/Search for all RNOs in a database.sql new file mode 100644 index 00000000..33272032 --- /dev/null +++ b/PROMS/SQL Data Tools/Search for all RNOs in a database.sql @@ -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) \ No newline at end of file diff --git a/PROMS/SQL Data Tools/SectionFormats.sql b/PROMS/SQL Data Tools/SectionFormats.sql new file mode 100644 index 00000000..6fab839e --- /dev/null +++ b/PROMS/SQL Data Tools/SectionFormats.sql @@ -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 diff --git a/PROMS/SQL Data Tools/SectionStartStatus.sql b/PROMS/SQL Data Tools/SectionStartStatus.sql new file mode 100644 index 00000000..3e66765b --- /dev/null +++ b/PROMS/SQL Data Tools/SectionStartStatus.sql @@ -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 +*/ \ No newline at end of file diff --git a/PROMS/SQL Data Tools/SectionStartStatusForGivenProcID.sql b/PROMS/SQL Data Tools/SectionStartStatusForGivenProcID.sql new file mode 100644 index 00000000..2ce1c448 --- /dev/null +++ b/PROMS/SQL Data Tools/SectionStartStatusForGivenProcID.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/SetDTS.sql b/PROMS/SQL Data Tools/SetDTS.sql new file mode 100644 index 00000000..8987d0eb --- /dev/null +++ b/PROMS/SQL Data Tools/SetDTS.sql @@ -0,0 +1,2 @@ +Update Items Set DTS = cast('12/30/2016' as datetime) +where ContentID in(select ContentID from Contents where Type = 0) diff --git a/PROMS/SQL Data Tools/SetSectionsToPrintWithBorders.sql b/PROMS/SQL Data Tools/SetSectionsToPrintWithBorders.sql new file mode 100644 index 00000000..dac82994 --- /dev/null +++ b/PROMS/SQL Data Tools/SetSectionsToPrintWithBorders.sql @@ -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' diff --git a/PROMS/SQL Data Tools/Setting the RO Path Prior to Exporting_BGE.sql b/PROMS/SQL Data Tools/Setting the RO Path Prior to Exporting_BGE.sql new file mode 100644 index 00000000..9a203ff0 --- /dev/null +++ b/PROMS/SQL Data Tools/Setting the RO Path Prior to Exporting_BGE.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Setting the RO Path Prior to Exporting_WCN.sql b/PROMS/SQL Data Tools/Setting the RO Path Prior to Exporting_WCN.sql new file mode 100644 index 00000000..3629d856 --- /dev/null +++ b/PROMS/SQL Data Tools/Setting the RO Path Prior to Exporting_WCN.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/Setting the RO Path Prior to Exporting_WEC.sql b/PROMS/SQL Data Tools/Setting the RO Path Prior to Exporting_WEC.sql new file mode 100644 index 00000000..d4fad552 --- /dev/null +++ b/PROMS/SQL Data Tools/Setting the RO Path Prior to Exporting_WEC.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/TurnChangeManagerON.sql b/PROMS/SQL Data Tools/TurnChangeManagerON.sql new file mode 100644 index 00000000..0ac163f3 --- /dev/null +++ b/PROMS/SQL Data Tools/TurnChangeManagerON.sql @@ -0,0 +1 @@ +vesp_TurnChangeManagerON \ No newline at end of file diff --git a/PROMS/SQL Data Tools/VerifyROFigureCount.sql b/PROMS/SQL Data Tools/VerifyROFigureCount.sql new file mode 100644 index 00000000..3a273d69 --- /dev/null +++ b/PROMS/SQL Data Tools/VerifyROFigureCount.sql @@ -0,0 +1 @@ +select ROFSTID, DTS, (Select Count( *) from Figures ff where ff.rofstid = ru.rofstid) ImageFiles from ROfsts ru \ No newline at end of file diff --git a/PROMS/SQL Data Tools/VersionAssocaitions.sql b/PROMS/SQL Data Tools/VersionAssocaitions.sql new file mode 100644 index 00000000..716b38c1 --- /dev/null +++ b/PROMS/SQL Data Tools/VersionAssocaitions.sql @@ -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 diff --git a/PROMS/SQL Data Tools/VersionRODBIDsDetail.sql b/PROMS/SQL Data Tools/VersionRODBIDsDetail.sql new file mode 100644 index 00000000..0fa14539 --- /dev/null +++ b/PROMS/SQL Data Tools/VersionRODBIDsDetail.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/VersionRODBIDsSummary.sql b/PROMS/SQL Data Tools/VersionRODBIDsSummary.sql new file mode 100644 index 00000000..cdb9f810 --- /dev/null +++ b/PROMS/SQL Data Tools/VersionRODBIDsSummary.sql @@ -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 \ No newline at end of file diff --git a/PROMS/SQL Data Tools/WEC2VCB_01_RemoveCoverSheets.sql b/PROMS/SQL Data Tools/WEC2VCB_01_RemoveCoverSheets.sql new file mode 100644 index 00000000..8ed4f32b --- /dev/null +++ b/PROMS/SQL Data Tools/WEC2VCB_01_RemoveCoverSheets.sql @@ -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) + diff --git a/PROMS/SQL Data Tools/WhatStepTypesAreTurnedOnInAllFormats_asofOct292015.sql b/PROMS/SQL Data Tools/WhatStepTypesAreTurnedOnInAllFormats_asofOct292015.sql new file mode 100644 index 00000000..1daf6046 --- /dev/null +++ b/PROMS/SQL Data Tools/WhatStepTypesAreTurnedOnInAllFormats_asofOct292015.sql @@ -0,0 +1 @@ +vesp_getFormatFieldsbysteptype inmenu \ No newline at end of file diff --git a/PROMS/SQL Data Tools/WideTables.sql b/PROMS/SQL Data Tools/WideTables.sql new file mode 100644 index 00000000..9e1b2bff --- /dev/null +++ b/PROMS/SQL Data Tools/WideTables.sql @@ -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 diff --git a/PROMS/SQL Data Tools/WideTablesBySet.sql b/PROMS/SQL Data Tools/WideTablesBySet.sql new file mode 100644 index 00000000..5f715b56 --- /dev/null +++ b/PROMS/SQL Data Tools/WideTablesBySet.sql @@ -0,0 +1,15 @@ +select FolderName, Contentid, Sum(Width)/72 WidthInches from ( +select FolderName, gg.contentid +,xWidth.value('.','int') Width +,xRows.value('.','int') Rows +,xColumns.value('.','int') Columns +from grids gg +join vefn_GetVersionItems('') VI ON VI.ContentID = GG.ContentID +join vefn_getVersionNames() VN ON VN.VersionID = VI.VersionID +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 FolderName, ContentID order by FolderName, sum(width) desc \ No newline at end of file diff --git a/PROMS/SQL Data Tools/XMLFormatQueries/AllFormats.sql b/PROMS/SQL Data Tools/XMLFormatQueries/AllFormats.sql new file mode 100644 index 00000000..ac3e0058 --- /dev/null +++ b/PROMS/SQL Data Tools/XMLFormatQueries/AllFormats.sql @@ -0,0 +1 @@ +select * from formats diff --git a/PROMS/SQL Data Tools/XMLFormatQueries/FindMissingAttibutes.sql b/PROMS/SQL Data Tools/XMLFormatQueries/FindMissingAttibutes.sql new file mode 100644 index 00000000..0f10df8e --- /dev/null +++ b/PROMS/SQL Data Tools/XMLFormatQueries/FindMissingAttibutes.sql @@ -0,0 +1,10 @@ +declare @FieldName as varchar(255) +set @FieldName = 'MatchProcNumber' +declare @NodeName as varchar(255) +set @NodeName = (Select distinct v.value('local-name(..)', 'varchar(255)') MyName FROM Formats CROSS APPLY Data.nodes('(*//@*[local-name()=sql:variable("@FieldName")])') TempXML(v)) +print @NodeName +Select * from ( +Select FormatID, Name, v.query('.') Node, +v.value('(./@*[local-name()=sql:variable("@FieldName")])[1]','varchar(255)') FieldValue +FROM Formats CROSS APPLY Data.nodes('(//*[local-name()=sql:variable("@NodeName")])') TempXML(v) +) t1 where FieldValue is null \ No newline at end of file diff --git a/PROMS/SQL Data Tools/XMLFormatQueries/FindMissingMatchProcNumber.sql b/PROMS/SQL Data Tools/XMLFormatQueries/FindMissingMatchProcNumber.sql new file mode 100644 index 00000000..7f66e906 --- /dev/null +++ b/PROMS/SQL Data Tools/XMLFormatQueries/FindMissingMatchProcNumber.sql @@ -0,0 +1,2 @@ +Select FormatID, Name, v.query('.') MyNode +FROM Formats CROSS APPLY Data.nodes('//ProcDescr[(not(@MatchProcNumber))]') TempXML(v) \ No newline at end of file diff --git a/PROMS/SQL Data Tools/XMLFormatQueries/FontsUsedByFontFor.sql b/PROMS/SQL Data Tools/XMLFormatQueries/FontsUsedByFontFor.sql new file mode 100644 index 00000000..a562eb3c --- /dev/null +++ b/PROMS/SQL Data Tools/XMLFormatQueries/FontsUsedByFontFor.sql @@ -0,0 +1,32 @@ +--Select * from( +SELECT FormatID, Name, Description +,v.query('.') FontNode +,v.query('..') ParentNode +--,v.value('../@Index', 'INT') AS [Index] +,v.value('../@Type', 'varchar(100)') AS Type +,v.value('../@ParentType', 'varchar(100)') AS ParentType +,v.value('@Family', 'varchar(30)') AS FontFamily +,v.value('@Size', 'INT') AS FontSize +,v.value('@Style', 'varchar(100)') AS FontStyle +,case + when v.exist('../../Step') = 1 then 'Step' + when v.exist('../../FormatData') = 1 then 'FormatData' + when v.exist('../../TabData') = 1 then 'TabData' + when v.exist('../../SectionHeader') = 1 then 'Section Header' + when v.exist('../../Separator') = 1 then 'Separator' + when v.exist('../../Item') = 1 then 'Item' + when v.exist('../../Continue') = 1 then 'Continue' + when v.exist('../../End') = 1 then 'End' + when v.exist('../../DocStyle') = 1 then 'DocStyle' + when v.exist('../../Box') = 1 then 'Box' + when v.exist('../../CheckOffHeader') = 1 then 'CheckOffHeader' + when v.exist('../../TableOfContentsData') = 1 then 'TableOfContentsData' + when v.exist('../../TopOfPage') = 1 then 'TopOfPage' + else null + end FontFor +FROM Formats +CROSS APPLY Data.nodes('//Font') TempXML(v) +--CROSS APPLY Data.nodes('//Step/Font') TempXML(v) +--CROSS APPLY Data.nodes('//FormatData/Font') TempXML(v) +--order by FormatID, v.value('../@Index', 'INT') +--) t1 where FontFor is null \ No newline at end of file diff --git a/PROMS/SQL Data Tools/XMLFormatQueries/FormatVariables.sql b/PROMS/SQL Data Tools/XMLFormatQueries/FormatVariables.sql new file mode 100644 index 00000000..6903cfe1 --- /dev/null +++ b/PROMS/SQL Data Tools/XMLFormatQueries/FormatVariables.sql @@ -0,0 +1,319 @@ +Select '//*[@AbsoluteFixedChangeColumn]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@AbsoluteFixedChangeColumn]') TempXML(v) UNION +Select '//*[@AbsoluteTransitionUpdate]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@AbsoluteTransitionUpdate]') TempXML(v) UNION +Select '//*[@AccessoryDocsInDuplex]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@AccessoryDocsInDuplex]') TempXML(v) UNION +Select '//*[@AdjRNOCol]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@AdjRNOCol]') TempXML(v) UNION +Select '//*[@AlignNullTabWSectHead]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@AlignNullTabWSectHead]') TempXML(v) UNION +Select '//*[@AllUnits]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@AllUnits]') TempXML(v) UNION +Select '//*[@AlternateFloatingFoldout]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@AlternateFloatingFoldout]') TempXML(v) UNION +Select '//*[@AlternateFoldoutPages]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@AlternateFoldoutPages]') TempXML(v) UNION +Select '//*[@AlwaysTab]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@AlwaysTab]') TempXML(v) UNION +Select '//*[@AlwaysUseExtraLines]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@AlwaysUseExtraLines]') TempXML(v) UNION +Select '//*[@AtLeastTwoDigits]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@AtLeastTwoDigits]') TempXML(v) UNION +Select '//*[@AutoContActSumSection]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@AutoContActSumSection]') TempXML(v) UNION +Select '//*[@BXHorz]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BXHorz]') TempXML(v) UNION +Select '//*[@BXLHorz]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BXLHorz]') TempXML(v) UNION +Select '//*[@BXLLC]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BXLLC]') TempXML(v) UNION +Select '//*[@BXLMID]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BXLMID]') TempXML(v) UNION +Select '//*[@BXLRC]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BXLRC]') TempXML(v) UNION +Select '//*[@BXMID]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BXMID]') TempXML(v) UNION +Select '//*[@BXMLS]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BXMLS]') TempXML(v) UNION +Select '//*[@BXMRS]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BXMRS]') TempXML(v) UNION +Select '//*[@BXULC]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BXULC]') TempXML(v) UNION +Select '//*[@BXUMID]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BXUMID]') TempXML(v) UNION +Select '//*[@BXURC]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BXURC]') TempXML(v) UNION +Select '//*[@BXVert]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BXVert]') TempXML(v) UNION +Select '//*[@BackColor]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BackColor]') TempXML(v) UNION +Select '//*[@BlankLineBeforeSubStep]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BlankLineBeforeSubStep]') TempXML(v) UNION +Select '//*[@BoldHighLevel]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BoldHighLevel]') TempXML(v) UNION +Select '//*[@BoldOnlySectionZero]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BoldOnlySectionZero]') TempXML(v) UNION +Select '//*[@BoxIt]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BoxIt]') TempXML(v) UNION +Select '//*[@Boxed]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Boxed]') TempXML(v) UNION +Select '//*[@Break]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Break]') TempXML(v) UNION +Select '//*[@BreakCautionsNotesOnSubstps]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BreakCautionsNotesOnSubstps]') TempXML(v) UNION +Select '//*[@BreakEquipmentList]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BreakEquipmentList]') TempXML(v) UNION +Select '//*[@BreakOnSections]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@BreakOnSections]') TempXML(v) UNION +Select '//*[@Bullet]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Bullet]') TempXML(v) UNION +Select '//*[@CancelSecTitlesOnE0]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CancelSecTitlesOnE0]') TempXML(v) UNION +Select '//*[@CancelSecTitlesOnE2]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CancelSecTitlesOnE2]') TempXML(v) UNION +Select '//*[@CancelSecTitlesOnS1]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CancelSecTitlesOnS1]') TempXML(v) UNION +Select '//*[@CancelSecTitlesOnS2]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CancelSecTitlesOnS2]') TempXML(v) UNION +Select '//*[@Cap1stCharTrans]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Cap1stCharTrans]') TempXML(v) UNION +Select '//*[@CapHighRo]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CapHighRo]') TempXML(v) UNION +Select '//*[@CapRoIfLastLower]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CapRoIfLastLower]') TempXML(v) UNION +Select '//*[@CapTranStep]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CapTranStep]') TempXML(v) UNION +Select '//*[@CapitalizeTitle]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CapitalizeTitle]') TempXML(v) UNION +Select '//*[@CapsTransitions]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CapsTransitions]') TempXML(v) UNION +Select '//*[@CenterOneLineAdjust]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CenterOneLineAdjust]') TempXML(v) UNION +Select '//*[@CenterOneLineOnly]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CenterOneLineOnly]') TempXML(v) UNION +Select '//*[@CenterTextWithinWidth]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CenterTextWithinWidth]') TempXML(v) UNION +Select '//*[@ChangeBarMessage' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ChangeBarMessage]' ) TempXML(v) UNION +Select '//*[@ChangeBarStyle]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ChangeBarStyle]') TempXML(v) UNION +Select '//*[@ChangeBarToRNOSep]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ChangeBarToRNOSep]') TempXML(v) UNION +Select '//*[@ChangeBarsOnLinkedText]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ChangeBarsOnLinkedText]') TempXML(v) UNION +Select '//*[@ChangeStyleForEverySection]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ChangeStyleForEverySection]') TempXML(v) UNION +Select '//*[@ChangeSummaryStyle]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ChangeSummaryStyle]') TempXML(v) UNION +Select '//*[@CheckOffAdjustment]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CheckOffAdjustment]') TempXML(v) UNION +Select '//*[@CheckOffHeading' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CheckOffHeading]' ) TempXML(v) UNION +Select '//*[@CheckOffOnAllSteps]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CheckOffOnAllSteps]') TempXML(v) UNION +Select '//*[@CheckOffOnHLSOnly]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CheckOffOnHLSOnly]') TempXML(v) UNION +Select '//*[@CheckOffWidAdjust]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CheckOffWidAdjust]') TempXML(v) UNION +Select '//*[@CheckOffs]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CheckOffs]') TempXML(v) UNION +Select '//*[@CheckOffSameAsParent]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CheckOffSameAsParent]') TempXML(v) UNION +Select '//*[@ChgBarMessageFromEdit]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ChgBarMessageFromEdit]') TempXML(v) UNION +Select '//*[@Col]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Col]') TempXML(v) UNION +Select '//*[@ColAbs]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ColAbs]') TempXML(v) UNION +Select '//*[@ColRScreen]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ColRScreen]') TempXML(v) UNION +Select '//*[@ColRTable]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ColRTable]') TempXML(v) UNION +Select '//*[@ColS]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ColS]') TempXML(v) UNION +Select '//*[@ColSByLevel]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ColSByLevel]') TempXML(v) UNION +Select '//*[@ColSScreenAdj]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ColSScreenAdj]') TempXML(v) UNION +Select '//*[@ColT]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ColT]') TempXML(v) UNION +Select '//*[@CompressHPSub]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CompressHPSub]') TempXML(v) UNION +Select '//*[@CompressHPSuper]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CompressHPSuper]') TempXML(v) UNION +Select '//*[@CompressSteps]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CompressSteps]') TempXML(v) UNION +Select '//*[@CondensedChangeBar]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CondensedChangeBar]') TempXML(v) UNION +Select '//*[@ContinueOnly]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ContinueOnly]') TempXML(v) UNION +Select '//*[@ContinueSectionHeader]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ContinueSectionHeader]') TempXML(v) UNION +Select '//*[@ContinuousChangeBars]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ContinuousChangeBars]') TempXML(v) UNION +Select '//*[@ConvertCaretToDelta]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ConvertCaretToDelta]') TempXML(v) UNION +Select '//*[@CountAllSubLevels]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CountAllSubLevels]') TempXML(v) UNION +Select '//*[@CountFoldoutPages]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CountFoldoutPages]') TempXML(v) UNION +Select '//*[@CoverTitleLength]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CoverTitleLength]') TempXML(v) UNION +Select '//*[@CustomSpacing]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@CustomSpacing]') TempXML(v) UNION +Select '//*[@DelimiterForTransitionTitle]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@DelimiterForTransitionTitle]') TempXML(v) UNION +Select '//*[@Desc]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Desc]') TempXML(v) UNION +Select '//*[@Dev_Format]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Dev_Format]') TempXML(v) UNION +Select '//*[@DoPrnDrvrAdjusts]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@DoPrnDrvrAdjusts]') TempXML(v) UNION +Select '//*[@DoRevDate]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@DoRevDate]') TempXML(v) UNION +Select '//*[@DoSTExtraAtTop]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@DoSTExtraAtTop]') TempXML(v) UNION +Select '//*[@DoSectionSeparatorLine]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@DoSectionSeparatorLine]') TempXML(v) UNION +Select '//*[@DoubleSpace]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@DoubleSpace]') TempXML(v) UNION +Select '//*[@DropCheckOff]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@DropCheckOff]') TempXML(v) UNION +Select '//*[@EMode]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@EMode]') TempXML(v) UNION +Select '//*[@End]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@End]') TempXML(v) UNION +Select '//*[@EndForSingle]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@EndForSingle]') TempXML(v) UNION +Select '//*[@EndMessagePos]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@EndMessagePos]') TempXML(v) UNION +Select '//*[@EnhancedShortFormDev]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@EnhancedShortFormDev]') TempXML(v) UNION +Select '//*[@EnhancedStepNumFromPrev]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@EnhancedStepNumFromPrev]') TempXML(v) UNION +Select '//*[@FixedAERChangeColumn' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@FixedAERChangeColumn]' ) TempXML(v) UNION +Select '//*[@FixedChangeColumn]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@FixedChangeColumn]') TempXML(v) UNION +Select '//*[@Flag]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Flag]') TempXML(v) UNION +Select '//*[@FloatingContinueMessage]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@FloatingContinueMessage]') TempXML(v) UNION +Select '//*[@FoldoutsInDuplex]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@FoldoutsInDuplex]') TempXML(v) UNION +Select '//*[@ForeColor]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ForeColor]') TempXML(v) UNION +Select '//*[@FortranFormatNumbers]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@FortranFormatNumbers]') TempXML(v) UNION +Select '//*[@HLRNOStpSeparatorString]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@HLRNOStpSeparatorString]') TempXML(v) UNION +Select '//*[@HLSWidthOVRD]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@HLSWidthOVRD]') TempXML(v) UNION +Select '//*[@HLStpSeparatorString]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@HLStpSeparatorString]') TempXML(v) UNION +Select '//*[@HardSpTranProcNumb]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@HardSpTranProcNumb]') TempXML(v) UNION +Select '//*[@Height]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Height]') TempXML(v) UNION +Select '//*[@HighLevelRNOBeforeAERSubsteps]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@HighLevelRNOBeforeAERSubsteps]') TempXML(v) UNION +Select '//*[@IdentB]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@IdentB]') TempXML(v) UNION +Select '//*[@ImmStepHdrCol]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ImmStepHdrCol]') TempXML(v) UNION +Select '//*[@ImperfectStructure]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ImperfectStructure]') TempXML(v) UNION +Select '//*[@ImperfectStructurePlus4]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ImperfectStructurePlus4]') TempXML(v) UNION +Select '//*[@ImperfectSubstep]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ImperfectSubstep]') TempXML(v) UNION +Select '//*[@InPageList]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@InPageList]') TempXML(v) UNION +Select '//*[@Inactive]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Inactive]') TempXML(v) UNION +Select '//*[@IndentToken]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@IndentToken]') TempXML(v) UNION +Select '//*[@Index]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Index]') TempXML(v) UNION +Select '//*[@Just]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Just]') TempXML(v) UNION +Select '//*[@KeepStepsOnPage]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@KeepStepsOnPage]') TempXML(v) UNION +Select '//*[@LJTabs]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@LJTabs]') TempXML(v) UNION +Select '//*[@LastLineToStartStep]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@LastLineToStartStep]') TempXML(v) UNION +Select '//*[@LeftJustify]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@LeftJustify]') TempXML(v) UNION +Select '//*[@LeftJustifyBorderless]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@LeftJustifyBorderless]') TempXML(v) UNION +Select '//*[@LineAboveUnderSection]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@LineAboveUnderSection]') TempXML(v) UNION +Select '//*[@LineDrawingOption]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@LineDrawingOption]') TempXML(v) UNION +Select '//*[@LowerCaseRevNum]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@LowerCaseRevNum]') TempXML(v) UNION +Select '//*[@LowerCaseStepInTran]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@LowerCaseStepInTran]') TempXML(v) UNION +Select '//*[@LowerCaseTranNumber]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@LowerCaseTranNumber]') TempXML(v) UNION +Select '//*[@LowerLimitDivisor]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@LowerLimitDivisor]') TempXML(v) UNION +Select '//*[@MatchProcNumber]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@MatchProcNumber]') TempXML(v) UNION +Select '//*[@MatchUpRNO]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@MatchUpRNO]') TempXML(v) UNION +Select '//*[@MaxRNO]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@MaxRNO]') TempXML(v) UNION +Select '//*[@MaxRNOTable]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@MaxRNOTable]') TempXML(v) UNION +Select '//*[@MetaSectEndMessage]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@MetaSectEndMessage]') TempXML(v) UNION +Select '//*[@MixCautionsAndNotes]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@MixCautionsAndNotes]') TempXML(v) UNION +Select '//*[@MultipleChangeIds]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@MultipleChangeIds]') TempXML(v) UNION +Select '//*[@Name]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Name]') TempXML(v) UNION +Select '//*[@NewlineAfter]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@NewlineAfter]') TempXML(v) UNION +Select '//*[@NonEditableSteps]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@NonEditableSteps]') TempXML(v) UNION +Select '//*[@NonLinkedCautNoteNumber]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@NonLinkedCautNoteNumber]') TempXML(v) UNION +Select '//*[@NonLinkedRNONumber]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@NonLinkedRNONumber]') TempXML(v) UNION +Select '//*[@NonLinkedStepNumber]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@NonLinkedStepNumber]') TempXML(v) UNION +Select '//*[@Number]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Number]') TempXML(v) UNION +Select '//*[@NumberHighLevel]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@NumberHighLevel]') TempXML(v) UNION +Select '//*[@NumberOfHighLevelSteps]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@NumberOfHighLevelSteps]') TempXML(v) UNION +Select '//*[@NumberOfSubStepTypes]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@NumberOfSubStepTypes]') TempXML(v) UNION +Select '//*[@NumberSubs]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@NumberSubs]') TempXML(v) UNION +Select '//*[@OffsetTab]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@OffsetTab]') TempXML(v) UNION +Select '//*[@OneLineBeforeTab]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@OneLineBeforeTab]') TempXML(v) UNION +Select '//*[@OnlySingleColumn]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@OnlySingleColumn]') TempXML(v) UNION +Select '//*[@OverrideEnhancedTabs]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@OverrideEnhancedTabs]') TempXML(v) UNION +Select '//*[@PMode]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PMode]') TempXML(v) UNION +Select '//*[@PSInfFile]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PSInfFile]') TempXML(v) UNION +Select '//*[@PageBreakOnFirstBlankLine]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PageBreakOnFirstBlankLine]') TempXML(v) UNION +Select '//*[@PageBreakOnStep]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PageBreakOnStep]') TempXML(v) UNION +Select '//*[@PagelistChangeIDsWithCommas]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PagelistChangeIDsWithCommas]') TempXML(v) UNION +Select '//*[@PaginateAtHighestPaginLevel]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PaginateAtHighestPaginLevel]') TempXML(v) UNION +Select '//*[@PaginateOnFirstSubstep]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PaginateOnFirstSubstep]') TempXML(v) UNION +Select '//*[@PaginateOnFirstSubstep2X]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PaginateOnFirstSubstep2X]') TempXML(v) UNION +Select '//*[@PaginateOnFirstSubstep3X]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PaginateOnFirstSubstep3X]') TempXML(v) UNION +Select '//*[@PaginateOnLowerStepLevel]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PaginateOnLowerStepLevel]') TempXML(v) UNION +Select '//*[@ParentType]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ParentType]') TempXML(v) UNION +Select '//*[@PartialStepCompression]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PartialStepCompression]') TempXML(v) UNION +Select '//*[@PicaIgnoreFiveSixths]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PicaIgnoreFiveSixths]') TempXML(v) UNION +Select '//*[@Pos]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Pos]') TempXML(v) UNION +Select '//*[@Prefix]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Prefix]') TempXML(v) UNION +Select '//*[@PrintNoTitle]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PrintNoTitle]') TempXML(v) UNION +Select '//*[@ProcDescr1]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ProcDescr1]') TempXML(v) UNION +Select '//*[@ProcDescr2]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ProcDescr2]') TempXML(v) UNION +Select '//*[@ProcedureSuffixFlags' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ProcedureSuffixFlags]' ) TempXML(v) UNION +Select '//*[@PromptForCautionType]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PromptForCautionType]') TempXML(v) UNION +Select '//*[@PurchaseOptions]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PurchaseOptions]') TempXML(v) UNION +Select '//*[@PutOnPageByItself]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@PutOnPageByItself]') TempXML(v) UNION +Select '//*[@Quoted]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Quoted]') TempXML(v) UNION +Select '//*[@RNO]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@RNO]') TempXML(v) UNION +Select '//*[@RNOSepString]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@RNOSepString]') TempXML(v) UNION +Select '//*[@RNOWidthAlt]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@RNOWidthAlt]') TempXML(v) UNION +Select '//*[@ReadOnlyTypeInContMsg]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ReadOnlyTypeInContMsg]') TempXML(v) UNION +Select '//*[@Rebox]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Rebox]') TempXML(v) UNION +Select '//*[@ReduceLineAfter]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ReduceLineAfter]') TempXML(v) UNION +Select '//*[@Remember]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Remember]') TempXML(v) UNION +Select '//*[@ReplaceWith]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ReplaceWith]') TempXML(v) UNION +Select '//*[@ReplaceWord]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ReplaceWord]') TempXML(v) UNION +Select '//*[@ReplaceWordsInROs]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ReplaceWordsInROs]') TempXML(v) UNION +Select '//*[@RevDateWithForwardSlash]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@RevDateWithForwardSlash]') TempXML(v) UNION +Select '//*[@RightCheckOffBoxChar]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@RightCheckOffBoxChar]') TempXML(v) UNION +Select '//*[@RightCheckOffChars]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@RightCheckOffChars]') TempXML(v) UNION +Select '//*[@RightCheckOffPrompt]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@RightCheckOffPrompt]') TempXML(v) UNION +Select '//*[@Row]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Row]') TempXML(v) UNION +Select '//*[@SameLevel]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SameLevel]') TempXML(v) UNION +Select '//*[@SameRowAsParent]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SameRowAsParent]') TempXML(v) UNION +Select '//*[@ScrnAdjRNOText]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ScrnAdjRNOText]') TempXML(v) UNION +Select '//*[@SearchAllReplaceWords]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SearchAllReplaceWords]') TempXML(v) UNION +Select '//*[@SecColHdrforActPMode]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SecColHdrforActPMode]') TempXML(v) UNION +Select '//*[@SecNumPositionAdj]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SecNumPositionAdj]') TempXML(v) UNION +Select '//*[@SecTitleContinue]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SecTitleContinue]') TempXML(v) UNION +Select '//*[@SecTitlePositionAdj]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SecTitlePositionAdj]') TempXML(v) UNION +Select '//*[@SectionLevelFoldouts]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SectionLevelFoldouts]') TempXML(v) UNION +Select '//*[@SectionTitleLength' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SectionTitleLength]' ) TempXML(v) UNION +Select '//*[@Sep]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Sep]') TempXML(v) UNION +Select '//*[@SepAfterAER]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SepAfterAER]') TempXML(v) UNION +Select '//*[@SeparateBox]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SeparateBox]') TempXML(v) UNION +Select '//*[@SeparateBoxCautions]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SeparateBoxCautions]') TempXML(v) UNION +Select '//Separator[@Location]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//Separator[@Location]' ) TempXML(v) UNION +Select '//*[@ShowSectionTitles]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ShowSectionTitles]') TempXML(v) UNION +Select '//*[@SpaceDouble]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SpaceDouble]') TempXML(v) UNION +Select '//*[@SpaceForNoSecNumb]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SpaceForNoSecNumb]') TempXML(v) UNION +Select '//*[@SpaceIn]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SpaceIn]') TempXML(v) UNION +Select '//*[@SpcHdr]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SpcHdr]') TempXML(v) UNION +Select '//*[@SpecialChangeBar' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SpecialChangeBar]' ) TempXML(v) UNION +Select '//*[@SpecialLandscapeMode]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SpecialLandscapeMode]') TempXML(v) UNION +Select '//*[@SpecialPageBreakFlag]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SpecialPageBreakFlag]') TempXML(v) UNION +Select '//*[@SpecialStepsFoldout]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SpecialStepsFoldout]') TempXML(v) UNION +Select '//*[@SpecifiedSubstepsOnly]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SpecifiedSubstepsOnly]') TempXML(v) UNION +Select '//*[@SplitStepInPrntStep]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SplitStepInPrntStep]') TempXML(v) UNION +Select '//*[@Start]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Start]') TempXML(v) UNION +Select '//*[@StartLineWithDash]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@StartLineWithDash]') TempXML(v) UNION +Select '//*[@StepNumIfOnlyOne]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@StepNumIfOnlyOne]') TempXML(v) UNION +Select '//*[@StepNumberForHighLevel]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@StepNumberForHighLevel]') TempXML(v) UNION +Select '//*[@StepSubstepDelimeter]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@StepSubstepDelimeter]') TempXML(v) UNION +Select '//*[@StepTypeColOverride]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@StepTypeColOverride]') TempXML(v) UNION +Select '//*[@SubPaginationWght]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SubPaginationWght]') TempXML(v) UNION +Select '//*[@SubTableGetsUp1Level]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SubTableGetsUp1Level]') TempXML(v) UNION +Select '//*[@Suffix]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Suffix]') TempXML(v) UNION +Select '//*[@SuppressAndInTran]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@SuppressAndInTran]') TempXML(v) UNION +Select '//*[@TStepNoFlag]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TStepNoFlag]') TempXML(v) UNION +Select '//*[@TabFormat]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TabFormat]') TempXML(v) UNION +Select '//*[@TabPos]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TabPos]') TempXML(v) UNION +Select '//*[@TableCenterPos]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TableCenterPos]') TempXML(v) UNION +Select '//*[@TextSubFollowsTextStyle]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TextSubFollowsTextStyle]') TempXML(v) UNION +Select '//*[@TextTitleAdjustment]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TextTitleAdjustment]') TempXML(v) UNION +Select '//*[@ThreeBlanksAbove]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ThreeBlanksAbove]') TempXML(v) UNION +Select '//*[@ThroughString]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@ThroughString]') TempXML(v) UNION +Select '//*[@TieTabToLevel]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TieTabToLevel]') TempXML(v) UNION +Select '//*[@TitleLength]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TitleLength]') TempXML(v) UNION +Select '//*[@TofCLineSpacing]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TofCLineSpacing]') TempXML(v) UNION +Select '//*[@TofCPageNumPos]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TofCPageNumPos]') TempXML(v) UNION +Select '//*[@TofCPositionAdj]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TofCPositionAdj]') TempXML(v) UNION +Select '//*[@TofCSecNumPos]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TofCSecNumPos]') TempXML(v) UNION +Select '//*[@TofCSecTitleLen]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TofCSecTitleLen]') TempXML(v) UNION +Select '//*[@TofCSecTitlePos]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TofCSecTitlePos]') TempXML(v) UNION +Select '//*[@TofCSpaceChar]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TofCSpaceChar]') TempXML(v) UNION +Select '//*[@TopOfPageThing]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TopOfPageThing]') TempXML(v) UNION +Select '//*[@TopRow]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TopRow]') TempXML(v) UNION +Select '//*[@TransFormat]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TransFormat]') TempXML(v) UNION +Select '//*[@TransMenu]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TransMenu]') TempXML(v) UNION +Select '//*[@TransType]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TransType]') TempXML(v) UNION +Select '//*[@TransUI]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TransUI]') TempXML(v) UNION +Select '//*[@TreatAsSequential]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TreatAsSequential]') TempXML(v) UNION +Select '//*[@TryToFillHalfOfPage]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TryToFillHalfOfPage]') TempXML(v) UNION +Select '//*[@TxtRowAdj]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TxtRowAdj]') TempXML(v) UNION +Select '//*[@TxtStart]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TxtStart]') TempXML(v) UNION +Select '//*[@TxtWidth]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@TxtWidth]') TempXML(v) UNION +Select '//*[@Type]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Type]') TempXML(v) UNION +Select '//*[@UndSpecialStepsFoldout]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UndSpecialStepsFoldout]') TempXML(v) UNION +Select '//*[@UnderlineAfterDashSpace]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UnderlineAfterDashSpace]') TempXML(v) UNION +Select '//*[@UnderlineAllMetaTitles]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UnderlineAllMetaTitles]') TempXML(v) UNION +Select '//*[@UnderlineRo]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UnderlineRo]') TempXML(v) UNION +Select '//*[@UnderlineTheseChar]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UnderlineTheseChar]') TempXML(v) UNION +Select '//*[@Unicode]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@Unicode]') TempXML(v) UNION +Select '//*[@UpRoAftrDash]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UpRoAftrDash]') TempXML(v) UNION +Select '//*[@UpRoIfPrevUpper]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UpRoIfPrevUpper]') TempXML(v) UNION +Select '//*[@UpcaseAllRoUnits]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UpcaseAllRoUnits]') TempXML(v) UNION +Select '//*[@UpcaseTranAnd]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UpcaseTranAnd]') TempXML(v) UNION +Select '//*[@UseAlternateStepBox]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseAlternateStepBox]') TempXML(v) UNION +Select '//*[@UseCheckOffsIn]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseCheckOffsIn]') TempXML(v) UNION +Select '//*[@UseHalfLines]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseHalfLines]') TempXML(v) UNION +Select '//*[@UseInAcTable]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseInAcTable]') TempXML(v) UNION +Select '//*[@UseMetaSections]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseMetaSections]') TempXML(v) UNION +Select '//*[@UseMultiLineSectionTitle]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseMultiLineSectionTitle]') TempXML(v) UNION +Select '//*[@UseSTExtraRealValue]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseSTExtraRealValue]') TempXML(v) UNION +Select '//*[@UseSecTitles]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseSecTitles]') TempXML(v) UNION +Select '//*[@UseSmartTemplate]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseSmartTemplate]') TempXML(v) UNION +Select '//*[@UseStepTypeWidthOverride]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseStepTypeWidthOverride]') TempXML(v) UNION +Select '//*[@UseStepTypeWidthOverrideEditPrint]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseStepTypeWidthOverrideEditPrint]') TempXML(v) UNION +Select '//*[@UseTopContinueMessageAtEnd]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseTopContinueMessageAtEnd]') TempXML(v) UNION +Select '//*[@UseTransitionModifier]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseTransitionModifier]') TempXML(v) UNION +Select '//*[@UseXtraRevNumber]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@UseXtraRevNumber]') TempXML(v) UNION +Select '//*[@VertPos]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@VertPos]') TempXML(v) UNION +Select '//*[@VirtualDotInHLSTab]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@VirtualDotInHLSTab]') TempXML(v) UNION +Select '//*[@WidSAdjByLevel]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@WidSAdjByLevel]') TempXML(v) UNION +Select '//*[@WidSTableEdit]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@WidSTableEdit]') TempXML(v) UNION +Select '//*[@WidSTablePrint]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@WidSTablePrint]') TempXML(v) UNION +Select '//*[@WidT]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@WidT]') TempXML(v) UNION +Select '//*[@WolfCreekBackgroundFormat]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@WolfCreekBackgroundFormat]') TempXML(v) UNION +Select '//*[@WolfcreekCKLBackgndFormat]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@WolfcreekCKLBackgndFormat]') TempXML(v) UNION +Select '//*[@WolfcreekCKLFormat]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@WolfcreekCKLFormat]') TempXML(v) UNION +Select '//*[@WrapSameAsEdit]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@WrapSameAsEdit]') TempXML(v) UNION +Select '//*[@XLines_StepFix]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@XLines_StepFix]') TempXML(v) UNION +Select '//*[@XchngTranSpForHard]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//*[@XchngTranSpForHard]') TempXML(v) UNION +Select '//Font/[@Family]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//Font[@Family]') TempXML(v) UNION +Select '//Font/[@Size]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//Font[@Size]') TempXML(v) UNION +Select '//Font/[@Style]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//Font[@Style]') TempXML(v) UNION +Select '//StepEditData/[@AcTable]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepEditData[@AcTable]') TempXML(v) UNION +Select '//StepEditData/[@BackColor]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepEditData[@BackColor]') TempXML(v) UNION +Select '//StepEditData/[@ForeColor]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepEditData[@ForeColor]') TempXML(v) UNION +Select '//StepEditData/[@Searchable]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepEditData[@Searchable]') TempXML(v) UNION +Select '//StepEditData/TypeMenu/[@AlternateNameList]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepEditData/TypeMenu[@AlternateNameList]') TempXML(v) UNION +Select '//StepEditData/TypeMenu/[@InMenu]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepEditData/TypeMenu[@InMenu]') TempXML(v) UNION +Select '//StepEditData/TypeMenu/[@MenuItem]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepEditData/TypeMenu[@MenuItem]') TempXML(v) UNION +Select '//StepEditData/TypeMenu/[@NoChgReason]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepEditData/TypeMenu[@NoChgReason]') TempXML(v) UNION +Select '//StepEditData/TypeMenu/[@RnoInMenu]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepEditData/TypeMenu[@RnoInMenu]') TempXML(v) UNION +Select '//StepEditData/TypeMenu/[@RnoMenuItem]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepEditData/TypeMenu[@RnoMenuItem]') TempXML(v) UNION +Select '//StepLayoutData/[@BackColor]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepLayoutData[@BackColor]') TempXML(v) UNION +Select '//StepLayoutData/[@EveryNLines]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepLayoutData[@EveryNLines]') TempXML(v) UNION +Select '//StepLayoutData/[@ForeColor]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepLayoutData[@ForeColor]') TempXML(v) UNION +Select '//StepLayoutData/[@STBoxindex]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepLayoutData[@STBoxindex]') TempXML(v) UNION +Select '//StepLayoutData/[@STExtraSpace]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepLayoutData[@STExtraSpace]') TempXML(v) UNION +Select '//StepPrintData/[@BackColor]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepPrintData[@BackColor]') TempXML(v) UNION +Select '//StepPrintData/[@ForeColor]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//StepPrintData[@ForeColor]') TempXML(v) UNION +Select '//TabData/[@IdentAltPrint]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//TabData[@IdentAltPrint]') TempXML(v) UNION +Select '//TabData/[@CheckOff]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//TabData[@CheckOff]') TempXML(v) UNION +Select '//TabData/[@Ident]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//TabData[@Ident]') TempXML(v) UNION +Select '//TabData/[@IdentEdit]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//TabData[@IdentEdit]') TempXML(v) UNION +Select '//TabData/[@Justify]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//TabData[@Justify]') TempXML(v) UNION +Select '//TabData/[@RNOIdent]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//TabData[@RNOIdent]') TempXML(v) UNION +Select '//TabData/[@RNOIdentEdit]' Path, Count(*) HowMany FROM Formats CROSS APPLY Data.nodes('//TabData[@RNOIdentEdit]') TempXML(v) \ No newline at end of file diff --git a/PROMS/SQL Data Tools/XMLFormatQueries/InactiveTypesEtc.sql b/PROMS/SQL Data Tools/XMLFormatQueries/InactiveTypesEtc.sql new file mode 100644 index 00000000..292e0326 --- /dev/null +++ b/PROMS/SQL Data Tools/XMLFormatQueries/InactiveTypesEtc.sql @@ -0,0 +1,70 @@ +-- NumberOfHighLevelSteps + +SELECT NumberOfHighLevelSteps ,Count(*) HowMany from ( +Select +v.value('@NumberOfHighLevelSteps', 'int') AS NumberOfHighLevelSteps +FROM Formats +CROSS APPLY Data.nodes('//*[@NumberOfHighLevelSteps]') TempXML(v) +) T1 Group by NumberOfHighLevelSteps + +-- NumberOfSubStepTypes + +SELECT NumberOfSubStepTypes ,Count(*) HowMany from ( +Select +--v.query('.') FontNode +v.value('@NumberOfSubStepTypes', 'int') AS NumberOfSubStepTypes +--,v.value('@Inactive', 'varchar(100)') AS InActive +FROM Formats +CROSS APPLY Data.nodes('//*[@NumberOfSubStepTypes]') TempXML(v) +) T1 Group by NumberOfSubStepTypes + +-- AlternateNameList + +SELECT AlternateNameList ,Count(*) HowMany from ( +SELECT +--V.query('../..') bozo, +v.value('@AlternateNameList', 'varchar(300)') AS AlternateNameList +FROM Formats +--CROSS APPLY Data.nodes('/Step []/StepEditData/TypeMenu') TempXML(v) +CROSS APPLY Data.nodes('//Step [@Type="Note"]/StepEditData/TypeMenu') TempXML(v) +) T1 Group by AlternateNameList + +-- InActive by Step Type + +SELECT TypeID,Type,InActive ,Count(*) HowManySELECT from ( +Select +v.query('.') FontNode, +v.value('@Index', 'int') AS TypeID +,v.value('@Type', 'varchar(100)') AS Type +,v.value('@Inactive', 'varchar(100)') AS InActive +FROM Formats +CROSS APPLY Data.nodes('//Step') TempXML(v) +) T1 Group by TypeID, Type, Inactive order by TypeID + +-- First Level Types + +SELECT DISTINCT +--,v.query('.') FontNode +v.value('@ParentType', 'varchar(100)') AS ParentType +,v.value('@Type', 'varchar(100)') AS Type +FROM Formats +CROSS APPLY Data.nodes('//Step[@ParentType="Base"]') TempXML(v) + +-- TabData/Fonts + +Select +v.query('..') as ParentNode +,v.query('.') as Node +,v.query('Font') as Font +FROM Formats +CROSS APPLY Data.nodes('//TabData[Font]') TempXML(v) + +-- UsePreviousStyle + +Select +Name,Description +,v.query('..') as ParentNode +,v.query('.') as Node +,v.query('Font') as Font +FROM Formats +CROSS APPLY Data.nodes('//TabData[@UsePreviousStyle]') TempXML(v) \ No newline at end of file diff --git a/PROMS/SQL Data Tools/XMLFormatQueries/SeqTabFmt.sql b/PROMS/SQL Data Tools/XMLFormatQueries/SeqTabFmt.sql new file mode 100644 index 00000000..59867b46 --- /dev/null +++ b/PROMS/SQL Data Tools/XMLFormatQueries/SeqTabFmt.sql @@ -0,0 +1,19 @@ +SELECT * FROM ( +SELECT FormatID,Name,ParentID +,isnull(v.value('@TabFormat', 'varchar(100)'),'*') AS [MyFormat] +,v.value('@Index', 'Int') AS [MyIndex] +From Formats +CROSS APPLY Data.nodes('//SeqTabFmt') TempXML(v) +) AS SRC +PIVOT( Max(MyFormat) FOR MyIndex IN ( +[0], [1],[2],[3],[4],[5],[6],[7],[8] +)) AS PVT1 Order by FormatID + + +SELECT FormatID,Name,Description,ParentID, v.query('../..') parentNode +,isnull(v.value('@TabFormat', 'varchar(100)'),'*') AS [MyFormat] +,v.value('@Index', 'Int') AS [MyIndex] +From Formats +CROSS APPLY Data.nodes('//SeqTabFmt') TempXML(v) + +select * from formats \ No newline at end of file diff --git a/PROMS/SQL Data Tools/XMLFormatQueries/StepFontPivots.sql b/PROMS/SQL Data Tools/XMLFormatQueries/StepFontPivots.sql new file mode 100644 index 00000000..17db54b6 --- /dev/null +++ b/PROMS/SQL Data Tools/XMLFormatQueries/StepFontPivots.sql @@ -0,0 +1,97 @@ +SELECT * FROM ( +SELECT FormatID,Name,ParentID +,isnull(v.value('Font[1]/@Family', 'varchar(100)'),'*') AS [MyFont] +,v.value('@Index', 'Int') AS [MyIndex] +From Formats +CROSS APPLY Data.nodes('//Step') TempXML(v) +) AS SRC +PIVOT( Max(MyFont) FOR MyIndex IN ( +[0], [1],[2],[3],[4],[5],[6],[7],[8],[9],[10], +[11],[12],[13],[14],[15],[16],[17],[18],[19],[20], +[21],[22],[23],[24],[25],[26],[27],[28],[29],[30], +[31],[32],[33],[34],[35],[36],[37],[38],[39],[40], +[41],[42],[43],[44],[45],[46] +)) AS PVT1 Order by FormatID + +SELECT * FROM ( +SELECT FormatID,Name,ParentID +,isnull(v.value('Font[1]/@Size', 'varchar(100)'),'*') AS [MyFont] +,v.value('@Index', 'Int') AS [MyIndex] +From Formats +CROSS APPLY Data.nodes('//Step') TempXML(v) +) AS SRC +PIVOT( Max(MyFont) FOR MyIndex IN ( +[0], [1],[2],[3],[4],[5],[6],[7],[8],[9],[10], +[11],[12],[13],[14],[15],[16],[17],[18],[19],[20], +[21],[22],[23],[24],[25],[26],[27],[28],[29],[30], +[31],[32],[33],[34],[35],[36],[37],[38],[39],[40], +[41],[42],[43],[44],[45],[46] +)) AS PVT1 Order by FormatID + + +SELECT * FROM ( +SELECT FormatID,Name,ParentID +,isnull(v.value('Font[1]/@Style', 'varchar(100)'),'*') AS [MyFont] +,v.value('@Index', 'Int') AS [MyIndex] +From Formats +CROSS APPLY Data.nodes('//Step') TempXML(v) +) AS SRC +PIVOT( Max(MyFont) FOR MyIndex IN ( +[0], [1],[2],[3],[4],[5],[6],[7],[8],[9],[10], +[11],[12],[13],[14],[15],[16],[17],[18],[19],[20], +[21],[22],[23],[24],[25],[26],[27],[28],[29],[30], +[31],[32],[33],[34],[35],[36],[37],[38],[39],[40], +[41],[42],[43],[44],[45],[46] +)) AS PVT1 Order by FormatID + + + + +SELECT v.value('@Index', 'Int') AS [MyIndex] +,v.value('@Type', 'varchar(100)') AS [MyType] +,v.value('@ParentType', 'varchar(100)') AS [MyParent] +From Formats +CROSS APPLY Data.nodes('//Step') TempXML(v) +WHERE FormatID=1 + +SELECT MyFont,Count(*) HowMany FROM ( +SELECT v.value('../@Family', 'varchar(100)') MyFont +From Formats +CROSS APPLY Data.nodes('//Step/Font') TempXML(v)) T1 +group by MyFont +order by MyFont + +SELECT MySize,Count(*) HowMany FROM ( +SELECT v.value('../@Size', 'varchar(100)') MySize +From Formats +CROSS APPLY Data.nodes('//Step/Font') TempXML(v)) T1 +group by MySize +order by MySize + +SELECT MyStyle,Count(*) HowMany FROM ( +SELECT v.value('../@Style', 'varchar(100)') MyStyle +From Formats +CROSS APPLY Data.nodes('//Step/Font') TempXML(v)) T1 +group by MyStyle +order by MyStyle + +SELECT MyFont,Count(*) HowMany FROM ( +SELECT v.value('@Family', 'varchar(100)') MyFont +From Formats +CROSS APPLY Data.nodes('//Font') TempXML(v)) T1 +group by MyFont +order by MyFont + +SELECT MySize,Count(*) HowMany FROM ( +SELECT v.value('@Size', 'varchar(100)') MySize +From Formats +CROSS APPLY Data.nodes('//Font') TempXML(v)) T1 +group by MySize +order by MySize + +SELECT MyStyle,Count(*) HowMany FROM ( +SELECT v.value('@Style', 'varchar(100)') MyStyle +From Formats +CROSS APPLY Data.nodes('//Font') TempXML(v)) T1 +group by MyStyle +order by MyStyle diff --git a/PROMS/SQL Data Tools/XMLFormatQueries/TabFormatPivot.sql b/PROMS/SQL Data Tools/XMLFormatQueries/TabFormatPivot.sql new file mode 100644 index 00000000..64546938 --- /dev/null +++ b/PROMS/SQL Data Tools/XMLFormatQueries/TabFormatPivot.sql @@ -0,0 +1,23 @@ +SELECT * FROM ( +Select FormatID, Name +, v.value('./@Index', 'int') MyIndex +, v.value('./@TabFormat', 'varchar(255)') TabFormat +--, v.value('./@PrintTabFormat', 'varchar(255)') PrintTabFormat +FROM Formats +CROSS APPLY Data.nodes('//SeqTabFmt') TempXML(v) +) AS SRC +PIVOT( Max(TabFormat) FOR MyIndex IN ( +[0], [1],[2],[3],[4],[5],[6],[7],[8] +)) AS PVT1 Order by FormatID + + +SELECT Max(MyIndex) FROM ( +Select FormatID, Name +, v.value('./@Index', 'int') MyIndex +, v.value('./@TabFormat', 'varchar(255)') TabFormat +--, v.value('./@PrintTabFormat', 'varchar(255)') PrintTabFormat +FROM Formats +CROSS APPLY Data.nodes('//SeqTabFmt') TempXML(v) +) AS SRC + + diff --git a/PROMS/SQL Data Tools/XMLFormatQueries/vlnFormatItemListIndexRanges.sql b/PROMS/SQL Data Tools/XMLFormatQueries/vlnFormatItemListIndexRanges.sql new file mode 100644 index 00000000..1c853533 --- /dev/null +++ b/PROMS/SQL Data Tools/XMLFormatQueries/vlnFormatItemListIndexRanges.sql @@ -0,0 +1,22 @@ +select --* +ListType,Count(*) HowMany, Min(IndexValue) MinIndexValue, Max(IndexValue) MaxIndexValue +from (SELECT Name, Description +,v.value('../@Index', 'varchar(100)') AS IndexValue +--,v.query('..') ParentNode +,case + when v.exist('../../SeqTabFmt') = 1 then 'SeqTabFmt' + when v.exist('../../Box') = 1 then 'Box' + when v.exist('../../CheckOffHeader') = 1 then 'CheckOffHeader' + when v.exist('../../DocStyle') = 1 then 'DocStyle' + when v.exist('../../Step') = 1 then 'Step' + when v.exist('../../TransTypes') = 1 then 'TransTypes' + when v.exist('../../PageStyle') = 1 then 'PageStyle' + when v.exist('../../RightCheckOffBox') = 1 then 'RightCheckOffBox' + when v.exist('../../CheckOff') = 1 then 'CheckOff' + when v.exist('../../MetaSection') = 1 then 'MetaSection' + else null + end ListType +FROM Formats +--CROSS APPLY Data.nodes('.//Step/Font') TempXML(v) +CROSS APPLY Data.nodes('//@Index') TempXML(v))t1 +group by ListType diff --git a/PROMS/SQL Data Tools/XMLFormatQueries/vlnFormatItemListsPivots.sql b/PROMS/SQL Data Tools/XMLFormatQueries/vlnFormatItemListsPivots.sql new file mode 100644 index 00000000..c14cb340 --- /dev/null +++ b/PROMS/SQL Data Tools/XMLFormatQueries/vlnFormatItemListsPivots.sql @@ -0,0 +1,86 @@ +/* +SELECT max(v.value('@Index', 'varchar(100)')) AS [MaxIndex] From Formats +CROSS APPLY Data.nodes('//DocStyle') TempXML(v) + +SELECT FormatID, Name,v.value('@Index', 'varchar(100)') AS [Index] From Formats +CROSS APPLY Data.nodes('//CheckOffHeader') TempXML(v) + +SELECT * FROM (SELECT FormatID,Name,v.value('@Index', 'varchar(100)') AS [MyIndex] From Formats +CROSS APPLY Data.nodes('//CheckOff') TempXML(v)) AS SRC +PIVOT( COUNT(MyIndex) FOR MyIndex IN ( +[0], [1], [2], [3], [4], [5], [6], [7], [8], [9],[10], +[11],[12],[13],[14],[15],[16],[17],[18],[19],[20], +[21],[22],[23],[24],[25],[26],[27],[28],[29],[30], +[31],[32],[33],[34],[35],[36],[37],[38],[39],[40], +[41],[42],[43],[44],[45],[46],[47],[48],[49],[50] +)) AS PVT Order by FormatID + +*/ +SELECT * FROM (SELECT FormatID,Name,ParentID,v.value('@Index', 'varchar(100)') AS [MyIndex] From Formats +CROSS APPLY Data.nodes('//DocStyle') TempXML(v)) AS SRC +PIVOT( COUNT(MyIndex) FOR MyIndex IN ( +[0], [1], [2], [3], [4], [5], [6], [7], [8], [9] +)) AS PVT Order by FormatID + +SELECT * FROM (SELECT FormatID,Name,ParentID,v.value('@Index', 'varchar(100)') AS [MyIndex] From Formats +CROSS APPLY Data.nodes('//PageStyle') TempXML(v)) AS SRC +PIVOT( COUNT(MyIndex) FOR MyIndex IN ( +[0], [1], [2], [3], [4], [5], [6], [7], [8], [9] +)) AS PVT Order by FormatID + +SELECT * FROM (SELECT FormatID,Name,ParentID,v.value('@Index', 'varchar(100)') AS [MyIndex] From Formats +CROSS APPLY Data.nodes('//RightCheckOffBox') TempXML(v)) AS SRC +PIVOT( COUNT(MyIndex) FOR MyIndex IN ( +[0], [1], [2], [3] +)) AS PVT Order by FormatID + +SELECT FormatID, Name,ParentID,v.value('@Index', 'varchar(100)') AS [Index] From Formats +CROSS APPLY Data.nodes('//CheckOffHeader') TempXML(v) + +SELECT * FROM (SELECT FormatID,Name,ParentID,v.value('@Index', 'varchar(100)') AS [MyIndex] From Formats +CROSS APPLY Data.nodes('//MetaSection') TempXML(v)) AS SRC +PIVOT( COUNT(MyIndex) FOR MyIndex IN ( +[0], [1], [2], [3] +)) AS PVT Order by FormatID + + +SELECT * FROM (SELECT FormatID,Name,ParentID,v.value('@Index', 'varchar(100)') AS [MyIndex] From Formats +CROSS APPLY Data.nodes('//CheckOff') TempXML(v)) AS SRC +PIVOT( COUNT(MyIndex) FOR MyIndex IN ( +[0],[1],[2],[3],[4],[5],[6],[7],[8],[9] +)) AS PVT Order by FormatID + +SELECT * FROM (SELECT FormatID,Name,ParentID,v.value('@Index', 'varchar(100)') AS [MyIndex] From Formats +CROSS APPLY Data.nodes('//Step') TempXML(v)) AS SRC +PIVOT( COUNT(MyIndex) FOR MyIndex IN ( +[0], [1],[2],[3],[4],[5],[6],[7],[8],[9],[10], +[11],[12],[13],[14],[15],[16],[17],[18],[19],[20], +[21],[22],[23],[24],[25],[26],[27],[28],[29],[30], +[31],[32],[33],[34],[35],[36],[37],[38],[39],[40], +[41],[42],[43],[44],[45],[46] +)) AS PVT Order by FormatID + +SELECT * FROM (SELECT FormatID,Name,ParentID,v.value('@Index', 'varchar(100)') AS [MyIndex] From Formats +CROSS APPLY Data.nodes('//SeqTabFmt') TempXML(v)) AS SRC +PIVOT( COUNT(MyIndex) FOR MyIndex IN +([0],[1],[2],[3],[4],[5],[6],[7],[8]) +) AS PVT Order by FormatID + +SELECT * FROM (SELECT FormatID,Name,ParentID,v.value('@Index', 'varchar(100)') AS [MyIndex] From Formats +CROSS APPLY Data.nodes('//Box') TempXML(v)) AS SRC +PIVOT( COUNT(MyIndex) FOR MyIndex IN +([0],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10]) +) AS PVT Order by FormatID + +SELECT * FROM (SELECT FormatID,Name,ParentID,v.value('@Index', 'varchar(100)') AS [MyIndex] From Formats +CROSS APPLY Data.nodes('//TransTypes') TempXML(v)) AS SRC +PIVOT( COUNT(MyIndex) FOR MyIndex IN +([0],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14]) +) AS PVT Order by FormatID + + + + + + + diff --git a/PROMS/SQL Data Tools/for Byron RO issue.sql b/PROMS/SQL Data Tools/for Byron RO issue.sql new file mode 100644 index 00000000..b6ae61dc --- /dev/null +++ b/PROMS/SQL Data Tools/for Byron RO issue.sql @@ -0,0 +1,8 @@ +----Get the VersionID for EOP Rev 3 + +--select * from vefn_GetVersionNames() +----On the next line Use The VersionID from EOP Rev 3 +--select * from Associations where VersionID = 14 +----Use the ROFSTID for the results +--Select * from ROFSTS where DTS IN(Select DTS From ROFSTs Where ROFSTID = 164) +----Get the RODBIDs for PROMS Data +--Select * from RODBs \ No newline at end of file diff --git a/PROMS/SQL Data Tools/getContentAuditsSummaryByItemIDandUnitID.SQL b/PROMS/SQL Data Tools/getContentAuditsSummaryByItemIDandUnitID.SQL new file mode 100644 index 00000000..6663334d --- /dev/null +++ b/PROMS/SQL Data Tools/getContentAuditsSummaryByItemIDandUnitID.SQL @@ -0,0 +1,132 @@ +/****** Object: StoredProcedure [dbo].[getContentAuditsSummaryByItemIDandUnitID] Script Date: 10/10/2012 12:56:01 ******/ +IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getContentAuditsSummaryByItemIDandUnitID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP PROCEDURE [getContentAuditsSummaryByItemIDandUnitID]; +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +/****** Object: StoredProcedure [getContentAuditsSummaryByItemIDandUnitID] ******/ +/* +getContentAuditsSummaryByItemIDandUnitID 146,146,0,1 +getContentAuditsSummaryByItemIDandUnitID 42,42,0,1 +getContentAuditsSummaryByItemIDandUnitID 1,1,0,1 +getContentAuditsSummaryByItemIDandUnitID 146,146,1,1 +*/ +/***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2012 - Volian Enterprises, Inc. All rights reserved. +*****************************************************************************/ +create PROCEDURE [dbo].[getContentAuditsSummaryByItemIDandUnitID] +( + @ProcedureItemID int, + @SelectedItemID int, + @IncludeDeletedChildren int, + @UnitID int, + @DTS datetime +) + +WITH EXECUTE AS OWNER +AS +begin +DECLARE @ProcId Int +Set @ProcID = @ProcedureItemID +DECLARE @Apples TABLE +( +ProcID int, +ItemId int, +ContentID int Primary Key, +Apple nvarchar(255), +DerApple nvarchar(255) +) +--Build Applicabilty table for the specified Procedure ID +BEGIN + with Itemz([Level],[Apple],[DerApple],[ParApple],[ItemID], [ContentID]) as + (Select 0 + ,xMasterSlave.value('@Applicability','nvarchar(255)') Apple + ,IsNull(xMasterSlave.value('@Applicability','nvarchar(255)'),dbo.ve_getItemDerivedApplicability(@ProcID)) DerApple + ,dbo.ve_getItemDerivedApplicability(@ProcID) ParApple + ,[II].[ItemID], [II].[ContentID] + FROM [Items] II + JOIN (Select ContentID, cast(config as XML) xConfig FROM Contents) CC ON II.ContentID = CC.ContentID + outer apply xConfig.nodes('//MasterSlave') tMasterSlave(xMasterSlave) + Where II.[ItemID] = @ProcID + Union All + -- Children + select ZZ.Level + 1 Level + ,xMasterSlave.value('@Applicability','nvarchar(255)') Apple + ,IsNull(xMasterSlave.value('@Applicability','nvarchar(255)'),ZZ.DerApple) DerApple + ,ZZ.DerApple ParApple + , II.[ItemID], II.[ContentID] + from Itemz ZZ + join Parts PP on PP.ContentID = ZZ.ContentID + join Items II on II.ItemID = PP.ItemID + JOIN (Select ContentID, cast(config as XML) xConfig FROM Contents) CC ON II.ContentID = CC.ContentID + outer apply xConfig.nodes('//MasterSlave') tMasterSlave(xMasterSlave) + Union All + -- Siblings + select ZZ.Level + ,xMasterSlave.value('@Applicability','nvarchar(255)') Apple + ,IsNull(xMasterSlave.value('@Applicability','nvarchar(255)'),ZZ.ParApple) DerApple + ,ZZ.ParApple + , II.[ItemID], II.[ContentID] + from Itemz ZZ + join Items II on II.PreviousID = ZZ.ItemID + JOIN (Select ContentID, cast(config as XML) xConfig FROM Contents) CC ON II.ContentID = CC.ContentID + outer apply xConfig.nodes('//MasterSlave') tMasterSlave(xMasterSlave) + Where Level >= 1 + ) + insert into @Apples + select @ProcID ProcID, ItemID, ContentID, Apple, DerApple--, [ItemID], [ContentID] + from ItemZ II + OPTION (MAXRECURSION 10000) +END + + +DECLARE @Chrono TABLE +( +[AuditID] bigint, +[ContentID] int, +[Number] nvarchar(max), +[Text] nvarchar(max), +[Type] int, +[FormatID] int, +[Config] nvarchar(max), +[DTS] datetime, +[UserID] nvarchar(max), +[DeleteStatus] int, +[ActionDTS] datetime, +[ActionWhat] nvarchar(max), +[ActionWhen] datetime, +[Path] nvarchar(max), +ItemID int, +TypeName nvarchar(max), +ordinalpath nvarchar(max) +) + +-- Use the Applicability Table to limit Items included in the list of changes +insert into @Chrono +select Distinct VC.* from vefn_GetMyChronology(@ProcedureItemID,@SelectedItemID,@IncludeDeletedChildren,@DTS) VC +Left JOIN @Apples AA ON AA.ContentID = VC.ContentID +Where aa.ContentID is null or AA.DerApple = '-1' or ',' + AA.DerApple + ',' like '%,' + cast(@UnitID as varchar(10)) + ',%' + +Declare @Audits TABLE +( +AuditID int primary key +) +-- Create a Unique list of Minimum and Maximum AuditIDs for Each ContentID +insert into @Audits +select min(auditID) from @Chrono group by contentid UNION select max(auditID) from @Chrono group by contentid +-- Return the List Of Changes with the first Audit Record and the Last Audit Record +select * from @Chrono +where AuditID is null OR AuditID in (select AuditID from @Audits) +order by OrdinalPath, contentid,auditid + + RETURN +end +GO +-- Display the status of Proc creation +IF (@@Error = 0) PRINT 'Procedure Creation: getContentAuditsSummaryByItemIDandUnitID Succeeded' +ELSE PRINT 'Procedure Creation: getContentAuditsSummaryByItemIDandUnitID Error on Creation' +GO diff --git a/PROMS/SQL Data Tools/updated - SQL queryt to aid in finding invalid RO tokens in MSWord sections._files/colorschememapping.xml b/PROMS/SQL Data Tools/updated - SQL queryt to aid in finding invalid RO tokens in MSWord sections._files/colorschememapping.xml new file mode 100644 index 00000000..6a0069cd --- /dev/null +++ b/PROMS/SQL Data Tools/updated - SQL queryt to aid in finding invalid RO tokens in MSWord sections._files/colorschememapping.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/PROMS/SQL Data Tools/updated - SQL queryt to aid in finding invalid RO tokens in MSWord sections._files/filelist.xml b/PROMS/SQL Data Tools/updated - SQL queryt to aid in finding invalid RO tokens in MSWord sections._files/filelist.xml new file mode 100644 index 00000000..cf743373 --- /dev/null +++ b/PROMS/SQL Data Tools/updated - SQL queryt to aid in finding invalid RO tokens in MSWord sections._files/filelist.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/PROMS/SQL Data Tools/updated - SQL queryt to aid in finding invalid RO tokens in MSWord sections._files/themedata.thmx b/PROMS/SQL Data Tools/updated - SQL queryt to aid in finding invalid RO tokens in MSWord sections._files/themedata.thmx new file mode 100644 index 00000000..55426d8e Binary files /dev/null and b/PROMS/SQL Data Tools/updated - SQL queryt to aid in finding invalid RO tokens in MSWord sections._files/themedata.thmx differ diff --git a/PROMS/SQL Data Tools/vefn_FindTransPrefixAndSuffix.sql b/PROMS/SQL Data Tools/vefn_FindTransPrefixAndSuffix.sql new file mode 100644 index 00000000..125bb0bf --- /dev/null +++ b/PROMS/SQL Data Tools/vefn_FindTransPrefixAndSuffix.sql @@ -0,0 +1,57 @@ +/* +select cc.ContentID--, Text +, T1.* +from (select * from contents where text like '%#Link:Tran%' and contentID not in(Select fromid from transitions)) cc +cross apply vefn_FindTransPrefixAndSuffix(cc.text) t1 + + + +*/ +alter FUNCTION [dbo].[vefn_FindTransPrefixAndSuffix](@text varchar(MAX)) +RETURNS @Transitions TABLE +( + Prefix nvarchar(Max), + Value nvarchar(Max), + Suffix nvarchar(Max) +) +WITH EXECUTE AS OWNER +AS +BEGIN + + -- DECLARE @text nvarchar(max) +--SET @Text = 'PERFORM a Source Check PER Section \v \v0 .' +--SET @Text = 'IMPLEMENT \v \v0' + DECLARE @index0 int + DECLARE @index1 int + DECLARE @index2 int + DECLARE @index3 int + DECLARE @index4 int + DECLARE @index5 int + DECLARE @prefix nvarchar(max) + DECLARE @value nvarchar(max) + DECLARE @suffix nvarchar(max) + DECLARE @rtext nvarchar(max) + SET @rtext = Reverse(@Text) + SET @index4 = CHARINDEX(' #Link:Transition' , @Text) + WHILE (@index4 > 0) + BEGIN + SET @index1 = CHARINDEX(Reverse('',@text, @index3)+5 + SET @index5 = charindex(' ',@text,@index5)+1 + if(@Index5 = 1) Set @Index5 = len(@text)+1 + --print @index5 + SET @value=substring(@text,@index2,@index3-@index2) + --print + SET @suffix = substring(@text,@index3,@index5-@index3) + --print '{' + @prefix + '}{' + @value + '}{' + @suffix + '}' + INSERT INTO @Transitions VALUES (@Prefix,@Value,@Suffix) + SET @index4 = CHARINDEX(' #Link:Transition' , @Text, @index5) + END + RETURN +END \ No newline at end of file