The Identify and Purge Disconnected data will now check and remove database records that have a FromType of zero.
This commit is contained in:
parent
e4a33c4471
commit
67dda748e6
@ -10273,7 +10273,7 @@ GO
|
|||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||||
Copyright 2013 - Volian Enterprises, Inc. All rights reserved.
|
Copyright 2017 - Volian Enterprises, Inc. All rights reserved.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
CREATE FUNCTION [dbo].[vefn_GetDisconnectedItems]()
|
CREATE FUNCTION [dbo].[vefn_GetDisconnectedItems]()
|
||||||
@ -10296,6 +10296,8 @@ BEGIN
|
|||||||
where ItemID not in(select ItemID from @UsedItems)) ii
|
where ItemID not in(select ItemID from @UsedItems)) ii
|
||||||
Join Contents CC ON CC.ContentID = II.ContentID
|
Join Contents CC ON CC.ContentID = II.ContentID
|
||||||
And CC.Type is not null
|
And CC.Type is not null
|
||||||
|
UNION
|
||||||
|
Select ItemId, ContentID from vefn_GetZeroFromType()
|
||||||
RETURN
|
RETURN
|
||||||
END
|
END
|
||||||
GO
|
GO
|
||||||
@ -11295,13 +11297,14 @@ GO
|
|||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||||
Copyright 2016 - Volian Enterprises, Inc. All rights reserved.
|
Copyright 2017 - Volian Enterprises, Inc. All rights reserved.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
CREATE PROCEDURE [dbo].[vesp_PurgeDisconnectedData]
|
CREATE PROCEDURE [dbo].[vesp_PurgeDisconnectedData]
|
||||||
WITH EXECUTE AS OWNER
|
WITH EXECUTE AS OWNER
|
||||||
AS
|
AS
|
||||||
BEGIN TRY -- Try Block
|
BEGIN TRY -- Try Block
|
||||||
BEGIN TRANSACTION
|
BEGIN TRANSACTION
|
||||||
|
delete from tblParts where FromType=0
|
||||||
declare @UsedItems Table
|
declare @UsedItems Table
|
||||||
( itemid int primary key, contentID int )
|
( itemid int primary key, contentID int )
|
||||||
insert into @UsedItems
|
insert into @UsedItems
|
||||||
@ -13354,6 +13357,57 @@ IF (@@Error = 0) PRINT 'Procedure Creation: getUsers Succeeded'
|
|||||||
ELSE PRINT 'Procedure Creation: getUsers Error on Creation'
|
ELSE PRINT 'Procedure Creation: getUsers Error on Creation'
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_GetZeroFromType]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
|
||||||
|
DROP FUNCTION [vefn_GetZeroFromType];
|
||||||
|
GO
|
||||||
|
/****** Object: UserDefinedFunction [dbo].[vefn_GetZeroFromType] ******/
|
||||||
|
SET ANSI_NULLS ON
|
||||||
|
GO
|
||||||
|
SET QUOTED_IDENTIFIER ON
|
||||||
|
GO
|
||||||
|
/*
|
||||||
|
Select * from vefn_GetZeroFromType()
|
||||||
|
*/
|
||||||
|
/*****************************************************************************
|
||||||
|
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||||
|
Copyright 2017 - Volian Enterprises, Inc. All rights reserved.
|
||||||
|
*****************************************************************************/
|
||||||
|
CREATE FUNCTION [dbo].[vefn_GetZeroFromType]()
|
||||||
|
RETURNS @DiscItems TABLE
|
||||||
|
(
|
||||||
|
ItemID int primary Key,
|
||||||
|
ContentID int,
|
||||||
|
UNIQUE (ContentID)
|
||||||
|
)
|
||||||
|
WITH EXECUTE AS OWNER
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
with ItemZ (BaseID, ItemID, ContentID) as
|
||||||
|
(Select PP.ContentID BaseID, II.ItemID, II.ContentID from Items II
|
||||||
|
Join Parts PP ON PP.ItemID = II.ItemID
|
||||||
|
where FromType = 0
|
||||||
|
Union All
|
||||||
|
-- Children
|
||||||
|
select z.BaseID, I.[ItemID], I.[ContentID]
|
||||||
|
from Itemz Z
|
||||||
|
join Parts P on P.ContentID = Z.ContentID
|
||||||
|
join Items I on I.ItemID = P.ItemID
|
||||||
|
Union All
|
||||||
|
-- Siblings
|
||||||
|
select z.BaseID, I.[ItemID], I.[ContentID]
|
||||||
|
from Itemz Z
|
||||||
|
join Items I on I.PreviousID = Z.ItemID
|
||||||
|
)
|
||||||
|
--select *, dbo.ve_GetShortPath(ItemID) Location from ItemZ
|
||||||
|
insert into @DiscItems
|
||||||
|
Select ItemID, ContentID from ItemZ
|
||||||
|
RETURN
|
||||||
|
END
|
||||||
|
|
||||||
|
go
|
||||||
|
IF (@@Error = 0) PRINT 'TableFunction [vefn_GetZeroFromType] Succeeded'
|
||||||
|
ELSE PRINT 'TableFunction [vefn_GetZeroFromType] Error on Creation'
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
/*
|
/*
|
||||||
@ -13380,8 +13434,8 @@ BEGIN TRY -- Try Block
|
|||||||
set nocount on
|
set nocount on
|
||||||
DECLARE @RevDate varchar(255)
|
DECLARE @RevDate varchar(255)
|
||||||
DECLARE @RevDescription varchar(255)
|
DECLARE @RevDescription varchar(255)
|
||||||
set @RevDate = '7/20/2017 11:00 AM'
|
set @RevDate = '7/25/2017 9:35 AM'
|
||||||
set @RevDescription = 'Sort users list'
|
set @RevDescription = 'Added vefn_GetZeroFromType and modified Disconnected Data'
|
||||||
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
|
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
|
||||||
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
|
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
|
||||||
IF( @@TRANCOUNT > 0 ) COMMIT
|
IF( @@TRANCOUNT > 0 ) COMMIT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user