Compare commits
134 Commits
B2026-018_
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 124cfb14ab | |||
| 604b4d1751 | |||
| 874aaf2857 | |||
| 17a28def4e | |||
| e72a1aa9e7 | |||
| 7b96ef1b4c | |||
| 4852b7c2c0 | |||
| dd4b08ec2b | |||
| 6aef00ffc6 | |||
| 76eb6fca13 | |||
| 892b84690e | |||
| b0bfb4d3f6 | |||
| af1a05ff40 | |||
| de89200eae | |||
| 7009ca78f2 | |||
| 03c58b7ae3 | |||
| c9166f6f92 | |||
| 343d6a8c9a | |||
| 8c5c7a5d93 | |||
| 864ec2709c | |||
| 4b1ca8d7bf | |||
| 3b73d54ea2 | |||
| 2ca433c83f | |||
| 0b40569727 | |||
| afb0247d87 | |||
| bce8461a7e | |||
| 9d5cc43d71 | |||
| bc1370ab29 | |||
| eaf2b14cfc | |||
| 1cf7d81aa5 | |||
| f11a9536f0 | |||
| c7bdcf0104 | |||
| df026499d5 | |||
| a3aa4157b8 | |||
| 8f3268e1bc | |||
| 5721d440e9 | |||
| 505c396283 | |||
| 643e6bc94f | |||
| 76502e6d97 | |||
| 851a0b3810 | |||
| fd8dbb4c8b | |||
| 4ffd994c5e | |||
| a34828113a | |||
| 461329468c | |||
| 35de5df04d | |||
| 4f0548fd60 | |||
| 5c1d96cc51 | |||
| 57049c0c52 | |||
| 31326e1c91 | |||
| 3c60994a0a | |||
| 773cc42346 | |||
| f46a1f39dc | |||
| b7175bf77f | |||
| ec22232aa8 | |||
| f303cd2236 | |||
| f40cef4416 | |||
| fbca97d38d | |||
| 28bd2cba5c | |||
| 4b35f73bbf | |||
| f4706eb126 | |||
| 21bcb90558 | |||
| ae48ac0cae | |||
| cb4979d5bc | |||
| 7d3ae74e1f | |||
| 9d680aa500 | |||
| 0d50b1c2fe | |||
| 75e034863f | |||
| 3b42de1571 | |||
| 668472286e | |||
| e00d34c99d | |||
| 9fb496dfb3 | |||
| f4eaa4a3ef | |||
| 5d50ed6bdf | |||
| d7ace4eaf9 | |||
| 16a4d335ea | |||
| ba69bb0772 | |||
| 455940caa2 | |||
| 439344757e | |||
| ad912691c9 | |||
| 237144aff6 | |||
| 810332d558 | |||
| f8431d0ba1 | |||
| 57c3bfa16a | |||
| 61f1077608 | |||
| 8877e968b9 | |||
| 4575c90bee | |||
| 21279a87ae | |||
| 3d5ad4a17e | |||
| 9bb7b044a8 | |||
| dc8f2f7561 | |||
| 829dbf84da | |||
| 7b156c17f8 | |||
| cbf7cbc164 | |||
| b04faa816e | |||
| 517ebe2902 | |||
| 03d0d314e3 | |||
| 3e804c5cce | |||
| ee2b8b538e | |||
| fdfd34fe92 | |||
| 2d6fb6523b | |||
| 3084bf3982 | |||
| 5ba51e8392 | |||
| fb5eb43e34 | |||
| b154056276 | |||
| c67b8f9ca1 | |||
| 95e4181360 | |||
| 32dffbe56b | |||
| 6b3c8d373b | |||
| db29107f47 | |||
| 355537f2ab | |||
| 0729ef0c21 | |||
| 6fe82bfd0f | |||
| 39bf072363 | |||
| da7c384fd8 | |||
| 95130fd9a0 | |||
| 978e2344a3 | |||
| c9bf45602c | |||
| aa160b2036 | |||
| f82b32d351 | |||
| e519dc9a57 | |||
| f020c37db9 | |||
| 5a4ec3b6b1 | |||
| 2602d6c9d2 | |||
| ff403583d7 | |||
| c5577cc2bd | |||
| 78be6e5dc1 | |||
| b954a41375 | |||
| 0100a11cfe | |||
| 04cf2e8534 | |||
| be00724818 | |||
| 274d93c61a | |||
| 7dc4c30436 | |||
| 028ef4bc31 | |||
| 42124d65c7 |
147
PROMS/SQL/ClientSpecific/BNPP_CoverPageConsolidation.sql
Normal file
147
PROMS/SQL/ClientSpecific/BNPP_CoverPageConsolidation.sql
Normal file
@@ -0,0 +1,147 @@
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2026 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
|
||||
-- =============================================
|
||||
-- Author: Matthew Schill
|
||||
-- Create date: 03/20/2026
|
||||
-- Description: Script to consolidate Cover Pages for Barakah
|
||||
-- by Converting multi-unit procedures with Cover Pages
|
||||
-- to use 1 Library Document Cover Page
|
||||
-- =============================================
|
||||
|
||||
select Contents.ContentID
|
||||
, Contenttext = Contents.Text
|
||||
, Items.ItemID
|
||||
, tblDocuments.DocID
|
||||
, ParentContentID
|
||||
, ParentItemID
|
||||
, LibTitle = ISNULL(LibTitle,'')
|
||||
, numLibCP
|
||||
, numCP
|
||||
,BaseFlag = 0
|
||||
INTO #tmpUpdate
|
||||
from Contents
|
||||
inner join Entries on Contents.ContentID = Entries.ContentID
|
||||
inner join tblDocuments on tblDocuments.DocID = Entries.DocID
|
||||
inner join Items on Items.ContentID = Contents.ContentID
|
||||
outer apply
|
||||
(select ParentContentID=ContentID, ParentItemID = PItm.ItemID
|
||||
FROM dbo.vefn_ParentItems(Items.ItemID) PItm
|
||||
where PItm.ItemID <> Items.ItemID
|
||||
) parent
|
||||
outer apply
|
||||
(select numLibCP = Count(*)
|
||||
FROM dbo.vefn_ChildItems(ParentItemID) PItm
|
||||
INNER JOIN Contents on Contents.ContentID = PItm.ContentID
|
||||
INNER JOIN Entries on Contents.ContentID = Entries.ContentID
|
||||
INNER JOIN tblDocuments on tblDocuments.DocID = Entries.DocID
|
||||
where PItm.ItemID <> ParentItemID
|
||||
AND Contents.text like 'Cover Page%' and ISNULL(tblDocuments.LibTitle,'') <> ''
|
||||
) childWithLibTitle
|
||||
outer apply
|
||||
(select numCP = Count(*)
|
||||
FROM dbo.vefn_ChildItems(ParentItemID) PItm
|
||||
INNER JOIN Contents on Contents.ContentID = PItm.ContentID
|
||||
where PItm.ItemID <> ParentItemID
|
||||
AND Contents.text like 'Cover Page%'
|
||||
) child
|
||||
where Contents.text like 'Cover Page%'
|
||||
order by ParentContentID asc, CASE WHEN ISNULL(LibTitle,'') <> '' THEN 1 ELSE 2 END asc, Contents.Text asc
|
||||
|
||||
UPDATE #tmpUpdate SET BaseFlag = 1 where LibTitle <> '' and numLibCP = 1
|
||||
|
||||
UPDATE #tmpUpdate SET BaseFlag = CASE WHEN tU.LibTitle <> '' THEN 1 ELSE 2 END FROM #tmpUpdate tU
|
||||
where BaseFlag = 0 AND tU.ContentID IN
|
||||
(
|
||||
Select ContentID FROM
|
||||
(SELECT sub.ContentID,
|
||||
row_number() OVER(PARTITION BY sub.ParentContentID ORDER BY CASE WHEN ISNULL(sub.LibTitle,'') <> '' THEN 1 ELSE 2 END asc, sub.Contenttext asc) as pos
|
||||
FROM #tmpUpdate sub
|
||||
) x
|
||||
WHERE x.pos = 1
|
||||
)
|
||||
|
||||
declare @Cont TABLE
|
||||
(
|
||||
ContentID int,
|
||||
ItemID int,
|
||||
xConfig xml
|
||||
)
|
||||
insert into @Cont
|
||||
SELECT tU.ContentID, ItemID, xConfig = CAST(tblContents.config AS xml) FROM
|
||||
tblContents
|
||||
INNER JOIN
|
||||
#tmpUpdate tU ON tU.ContentID = tblContents.ContentID
|
||||
where tU.BaseFlag > 0
|
||||
|
||||
Update @Cont Set xConfig.modify('delete //MasterSlave') From @Cont;
|
||||
|
||||
Update tblContents SET Text = 'Cover Page', Config = CAST(xConfig AS varchar(max)),
|
||||
DTS = GETDATE(), UserID = 'CPVolian2026'
|
||||
FROM
|
||||
@Cont CNT INNER JOIN
|
||||
tblContents ON CNT.ContentID = tblContents.ContentID;
|
||||
|
||||
--Update items PreviousIds
|
||||
UPDATE tblItems Set PreviousID = IdToSwapTO.ItemID
|
||||
FROM
|
||||
tblItems
|
||||
INNER JOIN
|
||||
#tmpUpdate tU ON tblItems.PreviousID = tU.ItemID AND tU.BaseFlag = 0
|
||||
INNER JOIN #tmpUpdate IdToSwapTO ON IdToSwapTO.ParentContentID = tU.ParentContentID AND IdToSwapTO.BaseFlag IN (1,2)
|
||||
|
||||
UPDATE tblItems Set DeleteStatus = 1, DTS = GETDATE(), UserID = 'CPVolian2026'
|
||||
FROM
|
||||
#tmpUpdate tU INNER JOIN
|
||||
tblItems ON tU.ContentID = tblItems.ContentID
|
||||
WHERE tU.BaseFlag = 0;
|
||||
|
||||
UPDATE tblContents Set DeleteStatus = 1, DTS = GETDATE(), UserID = 'CPVolian2026'
|
||||
FROM
|
||||
#tmpUpdate tU INNER JOIN
|
||||
tblContents ON tU.ContentID = tblContents.ContentID
|
||||
WHERE tU.BaseFlag = 0;
|
||||
|
||||
DELETE FROM
|
||||
tblEntries
|
||||
FROM
|
||||
tblEntries
|
||||
INNER JOIN
|
||||
#tmpUpdate tU ON tU.ContentID = tblEntries.ContentID
|
||||
WHERE tU.BaseFlag in (0,2);
|
||||
|
||||
INSERT INTO [dbo].[tblEntries]
|
||||
([ContentID]
|
||||
,[DocID]
|
||||
,[DTS]
|
||||
,[UserID]
|
||||
,[DeleteStatus])
|
||||
SELECT
|
||||
DISTINCT tU.ContentID,
|
||||
766, -- docid 766 "Cover Page 1"
|
||||
GETDATE(),
|
||||
'CPVolian2026',
|
||||
0
|
||||
FROM
|
||||
#tmpUpdate tU
|
||||
INNER JOIN
|
||||
@Cont CNT ON tU.ContentID = CNT.ContentID
|
||||
WHERE tU.BaseFlag = 2;
|
||||
|
||||
drop table #tmpUpdate;
|
||||
|
||||
IF (@@Error = 0) SELECT '[Barakah Cover Page Consolidation] Succeeded'
|
||||
ELSE SELECT '[Barakah Cover Page Consolidation] Error'
|
||||
go
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
263
PROMS/SQL/ClientSpecific/BNPP_CoverPageConsolidation_Test.sql
Normal file
263
PROMS/SQL/ClientSpecific/BNPP_CoverPageConsolidation_Test.sql
Normal file
@@ -0,0 +1,263 @@
|
||||
|
||||
-- =============================================
|
||||
-- Author: Matthew Schill
|
||||
-- Create date: 03/20/2026
|
||||
-- Description: Script to consolidate Cover Pages for Barakah
|
||||
-- by Converting multi-unit procedures with Cover Pages
|
||||
-- to use 1 Library Document Cover Page
|
||||
-- =============================================
|
||||
|
||||
----@isTest = 0 will change data
|
||||
----@isTest = 1 for internal testing (no data will be changed)
|
||||
DECLARE @isTest bit = 1;
|
||||
|
||||
----Per Cover Page, pull how many cover pages
|
||||
----Each Cover Page's procedure has
|
||||
----and how many of those are library documents
|
||||
select Contents.ContentID
|
||||
, Contenttext = Contents.Text
|
||||
, Items.ItemID
|
||||
, tblDocuments.DocID
|
||||
, ParentContentID
|
||||
, ParentItemID
|
||||
, LibTitle = ISNULL(LibTitle,'')
|
||||
, numLibCP
|
||||
, numCP
|
||||
,BaseFlag = 0
|
||||
INTO #tmpUpdate
|
||||
from Contents
|
||||
inner join Entries on Contents.ContentID = Entries.ContentID
|
||||
inner join tblDocuments on tblDocuments.DocID = Entries.DocID
|
||||
inner join Items on Items.ContentID = Contents.ContentID
|
||||
outer apply
|
||||
(select ParentContentID=ContentID, ParentItemID = PItm.ItemID
|
||||
FROM dbo.vefn_ParentItems(Items.ItemID) PItm
|
||||
where PItm.ItemID <> Items.ItemID
|
||||
) parent
|
||||
outer apply
|
||||
(select numLibCP = Count(*)
|
||||
FROM dbo.vefn_ChildItems(ParentItemID) PItm
|
||||
INNER JOIN Contents on Contents.ContentID = PItm.ContentID
|
||||
INNER JOIN Entries on Contents.ContentID = Entries.ContentID
|
||||
INNER JOIN tblDocuments on tblDocuments.DocID = Entries.DocID
|
||||
where PItm.ItemID <> ParentItemID
|
||||
AND Contents.text like 'Cover Page%' and ISNULL(tblDocuments.LibTitle,'') <> ''
|
||||
) childWithLibTitle
|
||||
outer apply
|
||||
(select numCP = Count(*)
|
||||
FROM dbo.vefn_ChildItems(ParentItemID) PItm
|
||||
INNER JOIN Contents on Contents.ContentID = PItm.ContentID
|
||||
where PItm.ItemID <> ParentItemID
|
||||
AND Contents.text like 'Cover Page%'
|
||||
) child
|
||||
where Contents.text like 'Cover Page%'
|
||||
order by ParentContentID asc, CASE WHEN ISNULL(LibTitle,'') <> '' THEN 1 ELSE 2 END asc, Contents.Text asc
|
||||
|
||||
--BaseFlag
|
||||
-- 0 = a Cover Page that will be deleted
|
||||
-- 1 = is base item (Cover Page will get renamed and applicability set to all)
|
||||
-- 2 = would be base item but not linked to Lib document (Cover Page will get renamed and applicability set to all + will need linked to library doc)
|
||||
|
||||
---- If only 1 Library Doc CP for the CP's procedure and this is it, then mark this CP as the one we will keep
|
||||
UPDATE #tmpUpdate SET BaseFlag = 1 where LibTitle <> '' and numLibCP = 1
|
||||
|
||||
---- If multiple Library Document CPs, pick the first one as the one we will keep (BaseFlag = 1)
|
||||
---- If no Library Document CPs, pick the first one as the one we will repurpose (BaseFlag = 2)
|
||||
UPDATE #tmpUpdate SET BaseFlag = CASE WHEN tU.LibTitle <> '' THEN 1 ELSE 2 END FROM #tmpUpdate tU
|
||||
where BaseFlag = 0 AND tU.ContentID IN
|
||||
(
|
||||
Select ContentID FROM
|
||||
(SELECT sub.ContentID,
|
||||
row_number() OVER(PARTITION BY sub.ParentContentID ORDER BY CASE WHEN ISNULL(sub.LibTitle,'') <> '' THEN 1 ELSE 2 END asc, sub.Contenttext asc) as pos
|
||||
FROM #tmpUpdate sub
|
||||
) x
|
||||
WHERE x.pos = 1
|
||||
)
|
||||
|
||||
----BEGIN TESTS--
|
||||
if(@isTest = 1)
|
||||
BEGIN
|
||||
select Count(*), 'Should be Zero - not exactly one BaseFlag set to non 0 for each Parent Item' FROM #tmpUpdate TU
|
||||
OUTER APPLY
|
||||
(select numBaseFlagSet = SUM(CASE WHEN sub.BaseFlag > 0 THEN 1 ELSE 0 END)
|
||||
FROM #tmpUpdate sub
|
||||
where sub.ParentContentID = TU.ParentContentID
|
||||
) sub
|
||||
where numBaseFlagSet <> 1
|
||||
|
||||
select Count(*), 'Should be Zero - 0 Lib Docs, BaseFlag is 1' FROM #tmpUpdate TU
|
||||
where numLibCP = 0 and BaseFlag = 1
|
||||
|
||||
select Count(*), 'Should be Zero - at least 1 Lib Docs, BaseFlag is 2' FROM #tmpUpdate TU
|
||||
where numLibCP > 0 and BaseFlag = 2
|
||||
|
||||
select Count(*), 'Should be Zero - 1 Lib Docs, BaseFlag not 1 for that Lib doc' FROM #tmpUpdate TU
|
||||
where numLibCP = 1 and LibTitle <> '' and BaseFlag <> 1
|
||||
|
||||
select Count(*), 'Should be Zero - 1 Lib Docs, BaseFlag not 0 for ones without Lib Doc' FROM #tmpUpdate TU
|
||||
where numLibCP = 1 and LibTitle = '' and BaseFlag <> 0
|
||||
|
||||
select Count(*), 'Should be Zero - 1 CP, no Lib Docs, BaseFlag not 2' FROM #tmpUpdate TU
|
||||
where numLibCP = 0 and numCP = 1 and BaseFlag <> 2
|
||||
|
||||
select Count(*), 'Should be Zero - more than 1 Lib Docs, BaseFlag is 1' FROM #tmpUpdate TU
|
||||
where numLibCP = 0 and BaseFlag = 1
|
||||
|
||||
select Count(*), 'Should be Zero - not exactly one BaseFlag set to non 0 for each Parent Item' FROM #tmpUpdate TU
|
||||
OUTER APPLY
|
||||
(select numBaseFlagSet = SUM(CASE WHEN sub.BaseFlag > 0 THEN 1 ELSE 0 END)
|
||||
FROM #tmpUpdate sub
|
||||
where sub.ParentContentID = TU.ParentContentID
|
||||
) sub
|
||||
where numBaseFlagSet <> 1
|
||||
|
||||
select Count(*), 'Should be Zero - 0 Lib Docs, BaseFlag is 1' FROM #tmpUpdate TU
|
||||
where numLibCP = 0
|
||||
and BaseFlag = 1
|
||||
|
||||
--all Parents should have exactly 1 Baseflag=1 or BaseFlage = 2
|
||||
select 'Should be No Records where not a BaseFlag 1 or 2'
|
||||
select NumNotBaseFlag12 = Count(*)
|
||||
FROM #tmpUpdate TU
|
||||
Group by ParentContentID
|
||||
HAVING SUM(CASE WHEN BaseFlag in (1,2) THEN 1 ELSE 0 END) <> 1
|
||||
|
||||
select 'Should be No Records where with both a BaseFlag 1 and 2'
|
||||
select NumBothBaseFlag12 = Count(*)
|
||||
FROM #tmpUpdate TU
|
||||
Group by ParentContentID
|
||||
HAVING SUM(BaseFlag) > 2
|
||||
|
||||
END
|
||||
--END TESTS--
|
||||
|
||||
--BaseFlag
|
||||
-- 0 = a Cover Page that will be deleted
|
||||
-- 1 = is base item (Cover Page will get renamed and applicability set to all)
|
||||
-- 2 = would be base item but not linked to Lib document (Cover Page will get renamed and applicability set to all + will need linked to library doc)
|
||||
|
||||
----Update config for Coverpage 1 to remove <MasterSlave Applicability="1" />
|
||||
----from that config
|
||||
----cover page 1s
|
||||
declare @Cont TABLE
|
||||
(
|
||||
ContentID int,
|
||||
ItemID int,
|
||||
xConfig xml
|
||||
)
|
||||
insert into @Cont
|
||||
SELECT tU.ContentID, ItemID, xConfig = CAST(tblContents.config AS xml) FROM
|
||||
tblContents
|
||||
INNER JOIN
|
||||
#tmpUpdate tU ON tU.ContentID = tblContents.ContentID
|
||||
where tU.BaseFlag > 0
|
||||
|
||||
if(@isTest = 1)
|
||||
BEGIN
|
||||
select WRD='Have Masterslave in xconfig', NumwithMasterSlave = Count(*) FROM @Cont CNT
|
||||
INNER JOIN
|
||||
tblContents ON CNT.ContentID = tblContents.ContentID
|
||||
where CAST(xConfig AS varchar(max)) like '%MasterSlave%'
|
||||
END
|
||||
|
||||
Update @Cont Set xConfig.modify('delete //MasterSlave') From @Cont;
|
||||
|
||||
if(@isTest = 1)
|
||||
BEGIN
|
||||
select WRD='None should have Masterslave Removed in xconfig', NumwithMasterSlave = Count(*) FROM @Cont CNT
|
||||
INNER JOIN
|
||||
tblContents ON CNT.ContentID = tblContents.ContentID
|
||||
where CAST(xConfig AS varchar(max)) like '%MasterSlave%'
|
||||
|
||||
select 'Show Records and how the ids will be re-linked'
|
||||
|
||||
Select tblItems.ItemID, tblItems.ContentID, tblItems.PreviousID, tblContents.Text,
|
||||
PreviousItemID = tU.ItemID, PreviousContentID = tU.ContentID, PreviousText = tUCont.Text,
|
||||
RelinkToItemID = IdToSwapTO.ItemID, RelinkToContentID = IdToSwapTO.ContentID, RelinkToText = IdToSwapTOCont.Text
|
||||
FROM
|
||||
tblItems
|
||||
INNER JOIN
|
||||
tblContents on tblContents.ContentID = tblItems.ContentID
|
||||
INNER JOIN
|
||||
#tmpUpdate tU ON tblItems.PreviousID = tU.ItemID AND tU.BaseFlag = 0
|
||||
INNER JOIN
|
||||
tblContents tUCont on tUCont.ContentID = tU.ContentID
|
||||
LEFT OUTER JOIN #tmpUpdate IdToSwapTO ON IdToSwapTO.ParentContentID = tU.ParentContentID AND IdToSwapTO.BaseFlag IN (1,2)
|
||||
LEFT OUTER JOIN tblContents IdToSwapTOCont on IdToSwapTOCont.ContentID = IdToSwapTO.ContentID
|
||||
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
--Update Config for Contents and set Text = 'Cover Page'
|
||||
Update tblContents SET Text = 'Cover Page', Config = CAST(xConfig AS varchar(max)),
|
||||
DTS = GETDATE(), UserID = 'CPVolian2026'
|
||||
FROM
|
||||
@Cont CNT INNER JOIN
|
||||
tblContents ON CNT.ContentID = tblContents.ContentID;
|
||||
|
||||
--Update items PreviousIds
|
||||
UPDATE tblItems Set PreviousID = IdToSwapTO.ItemID
|
||||
FROM
|
||||
tblItems
|
||||
INNER JOIN
|
||||
#tmpUpdate tU ON tblItems.PreviousID = tU.ItemID AND tU.BaseFlag = 0
|
||||
INNER JOIN #tmpUpdate IdToSwapTO ON IdToSwapTO.ParentContentID = tU.ParentContentID AND IdToSwapTO.BaseFlag IN (1,2)
|
||||
|
||||
--delete where BaseFlag = 0 ---Items,Content,Entries, --set DeleteStatus = 1
|
||||
--these are ones that will be replaced by a library document
|
||||
UPDATE tblItems Set DeleteStatus = 1, DTS = GETDATE(), UserID = 'CPVolian2026'
|
||||
FROM
|
||||
#tmpUpdate tU INNER JOIN
|
||||
tblItems ON tU.ContentID = tblItems.ContentID
|
||||
WHERE tU.BaseFlag = 0;
|
||||
|
||||
UPDATE tblContents Set DeleteStatus = 1, DTS = GETDATE(), UserID = 'CPVolian2026'
|
||||
FROM
|
||||
#tmpUpdate tU INNER JOIN
|
||||
tblContents ON tU.ContentID = tblContents.ContentID
|
||||
WHERE tU.BaseFlag = 0;
|
||||
|
||||
--delete entries where Baseflag = 2
|
||||
--create new entries where Baseflag = 2
|
||||
|
||||
DELETE FROM
|
||||
tblEntries
|
||||
FROM
|
||||
tblEntries
|
||||
INNER JOIN
|
||||
#tmpUpdate tU ON tU.ContentID = tblEntries.ContentID
|
||||
WHERE tU.BaseFlag in (0,2);
|
||||
|
||||
INSERT INTO [dbo].[tblEntries]
|
||||
([ContentID]
|
||||
,[DocID]
|
||||
,[DTS]
|
||||
,[UserID]
|
||||
,[DeleteStatus])
|
||||
SELECT
|
||||
DISTINCT tU.ContentID,
|
||||
766, -- docid 766 "Cover Page 1"
|
||||
GETDATE(),
|
||||
'CPVolian2026',
|
||||
0
|
||||
FROM
|
||||
#tmpUpdate tU
|
||||
INNER JOIN
|
||||
@Cont CNT ON tU.ContentID = CNT.ContentID
|
||||
WHERE tU.BaseFlag = 2;
|
||||
|
||||
END;
|
||||
|
||||
drop table #tmpUpdate;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user