C2016-022: Added purge of multiple RO/Associations and unused RoFsts and Figures

C2016-022: Additional admin tools queries for multiple RO/Associations & unused RoFsts and Figures
This commit is contained in:
2016-07-05 13:09:37 +00:00
parent 14bb3fcf3b
commit 12a3b053ac
3 changed files with 582 additions and 2 deletions

View File

@@ -12939,6 +12939,151 @@ go
PRINT 'Enhanced Document Synchronization code.'
/****** Object: StoredProcedure [vesp_GetUnusedRoFstsCount] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_GetUnusedRoFstsCount]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [vesp_GetUnusedRoFstsCount];
GO
/*
exec vesp_GetUnusedRoFstsCount
*/
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2016 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[vesp_GetUnusedRoFstsCount]
WITH EXECUTE AS OWNER
AS
Select COUNT(*) HowMany From ROFSTS where ROFstID not in(Select ROFSTID from Associations)
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: vesp_GetUnusedRoFstsCount Succeeded'
ELSE PRINT 'Procedure Creation: vesp_GetUnusedRoFstsCount Error on Creation'
GO
/****** Object: StoredProcedure [vesp_GetUnusedRoFstsCount] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_GetUnusedFiguresCount]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [vesp_GetUnusedFiguresCount];
GO
/*
exec vesp_GetUnusedFiguresCount
*/
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2016 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[vesp_GetUnusedFiguresCount]
WITH EXECUTE AS OWNER
AS
Select COUNT(*) HowMany from Figures where ROFstID not in(Select ROFSTID from Associations)
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: vesp_GetUnusedFiguresCount Succeeded'
ELSE PRINT 'Procedure Creation: vesp_GetUnusedFiguresCount Error on Creation'
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_RemoveUnusedRoFstsAndFigures]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [vesp_RemoveUnusedRoFstsAndFigures];
GO
/*
vesp_RemoveUnusedRoFstsAndFigures
*/
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2016 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[vesp_RemoveUnusedRoFstsAndFigures]
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
Delete From Figures where ROFstID not in(Select ROFSTID from Associations)
Delete From ROFSTS where ROFstID not in(Select ROFSTID from Associations)
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
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'StoredProcedure [vesp_RemoveUnusedRoFstsAndFigures] Succeeded'
ELSE PRINT 'StoredProcedure [vesp_RemoveUnusedRoFstsAndFigures] Error on Creation'
go
/****** Object: StoredProcedure [vesp_GetUnusedROAssociationsCount] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_GetUnusedROAssociationsCount]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [vesp_GetUnusedROAssociationsCount];
GO
/*
exec vesp_GetUnusedROAssociationsCount
*/
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2016 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[vesp_GetUnusedROAssociationsCount]
WITH EXECUTE AS OWNER
AS
--SELECT COUNT(*) HowMany FROM vefn_GetDisconnectedItems()
begin
with cte as (
Select *, Row_Number() over (partition by VersionID order by associationID ) MyRank from Associations
)
select count(*) HowMany from CTE where MyRank > 1
end
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: vesp_GetUnusedROAssociationsCount Succeeded'
ELSE PRINT 'Procedure Creation: vesp_GetUnusedROAssociationsCount Error on Creation'
GO
/****** Object: StoredProcedure [vesp_CleanUpROAssociations] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_CleanUpROAssociations]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [vesp_CleanUpROAssociations];
GO
/*
vesp_CleanUpROAssociations
*/
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2016 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[vesp_CleanUpROAssociations]
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
BEGIN
with cte as (
Select *, Row_Number() over (partition by VersionID order by associationID ) MyRank from Associations
)
delete CTE where MyRank > 1
END
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
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'StoredProcedure [vesp_CleanUpROAssociations] Succeeded'
ELSE PRINT 'StoredProcedure [vesp_CleanUpROAssociations] Error on Creation'
go
PRINT 'Admin Tools Additional queries for Cleanup RO Assoc and Cleanup of Unused RO Fsts and Figures.'
-----------------------------------------------------------------------------
/*
---------------------------------------------------------------------------
@@ -12964,8 +13109,8 @@ BEGIN TRY -- Try Block
set nocount on
DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255)
set @RevDate = '6/21/2016 11:29 AM'
set @RevDescription = 'Added logic to handle backslashes'
set @RevDate = '7/5/2016 10:00 AM'
set @RevDescription = 'Added admin tools for cleanup of ro assoc and unused rofst and figures'
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
IF( @@TRANCOUNT > 0 ) COMMIT