C2021-058 Admin Tool Purge Change History/C2025-052 Admin Tool Index Maintenance
This commit is contained in:
@@ -24264,6 +24264,129 @@ BEGIN
|
||||
RETURN
|
||||
END
|
||||
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: [getUserAcessControl] Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: [getUserAcessControl] Error on Creation'
|
||||
GO
|
||||
|
||||
-- C2021-058 Admin Tool Purge Change History / C2025-052 Admin Tool Index Maintenance
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_PurgeChangeHistory]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [vesp_PurgeChangeHistory];
|
||||
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_PurgeChangeHistory] Script Date: 9/9/2025 6:51:42 AM ******/
|
||||
|
||||
-- =============================================
|
||||
-- Author: Matthew Schill
|
||||
-- Create date: 09/09/2025
|
||||
-- Description: Admin Tool Purge Change History. Add the ability to remove audit records from Admin Tools.
|
||||
-- =============================================
|
||||
CREATE PROCEDURE [dbo].[vesp_PurgeChangeHistory]
|
||||
(
|
||||
@dte AS datetime
|
||||
)
|
||||
AS
|
||||
BEGIN
|
||||
Delete from Versions where DTS < @dte
|
||||
Delete from DocumentAudits where DTS < @dte
|
||||
delete from Figures where ROFSTID not in(select rofstid from Associations) and DTS < @dte
|
||||
Delete from ROFSTs where ROFSTID not in(select rofstid from Associations) and DTS < @dte
|
||||
delete from roimages where rodbid not in(select rodbid from rofsts) and DTS < @dte
|
||||
delete from documents where docid not in(select docid from entries) and DTS < @dte
|
||||
PRINT 'Phase 1'
|
||||
delete from tblAnnotations where deletestatus != 0 and DTS < @dte
|
||||
delete from drousages where docid in(select docid from tbldocuments where deletestatus != 0) and DTS < @dte
|
||||
delete from tblEntries where deletestatus != 0 and DTS < @dte
|
||||
delete from tblDocuments where deletestatus != 0 and DTS < @dte
|
||||
delete from tblGrids where deletestatus != 0 and DTS < @dte
|
||||
delete from tblImages where deletestatus != 0 and DTS < @dte
|
||||
PRINT 'Phase 2'
|
||||
delete from tblROUsages where deletestatus != 0 and DTS < @dte
|
||||
delete from tblTransitions where deletestatus != 0 and DTS < @dte
|
||||
delete from tblParts where deletestatus != 0 and DTS < @dte
|
||||
delete from tblItems where deletestatus != 0 and ItemID Not IN (Select ItemID from Parts) and DTS < @dte
|
||||
PRINT 'Purge Contents'
|
||||
delete from tblContents where deletestatus != 0 and DTS < @dte
|
||||
PRINT 'Phase 3'
|
||||
delete from AnnotationAudits where DTS < @dte
|
||||
delete from ContentAudits where DTS < @dte
|
||||
delete from EntryAudits where DTS < @dte
|
||||
delete from DocumentAudits where DTS < @dte
|
||||
delete from GridAudits where DTS < @dte
|
||||
delete from ImageAudits where DTS < @dte
|
||||
PRINT 'Phase 4'
|
||||
delete from ItemAudits where DTS < @dte
|
||||
delete from PartAudits where DTS < @dte
|
||||
delete from ROUsageAudits where DTS < @dte
|
||||
delete from TransitionAudits where DTS < @dte
|
||||
|
||||
RETURN
|
||||
END
|
||||
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_PurgeChangeHistory] Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: [vesp_PurgeChangeHistory] Error on Creation'
|
||||
GO
|
||||
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_IndexMaintenance]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [vesp_IndexMaintenance];
|
||||
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_IndexMaintenance] Script Date: 9/9/2025 7:54:42 AM ******/
|
||||
|
||||
-- =============================================
|
||||
-- Author: Matthew Schill
|
||||
-- Create date: 09/09/2025
|
||||
-- Description: Rebuild all indexes in the db
|
||||
-- =============================================
|
||||
CREATE PROCEDURE [dbo].[vesp_IndexMaintenance]
|
||||
With Execute as Owner
|
||||
AS
|
||||
BEGIN
|
||||
|
||||
Exec sp_msforeachtable 'SET QUOTED_IDENTIFIER ON; ALTER INDEX ALL ON ? REBUILD'
|
||||
|
||||
RETURN
|
||||
END
|
||||
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_IndexMaintenance] Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: [vesp_IndexMaintenance] Error on Creation'
|
||||
GO
|
||||
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_GetOtherActiveSessions]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [vesp_GetOtherActiveSessions];
|
||||
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[vesp_GetOtherActiveSessions] Script Date: 9/10/2025 7:54:42 AM ******/
|
||||
|
||||
-- =============================================
|
||||
-- Author: Matthew Schill
|
||||
-- Create date: 09/10/2025
|
||||
-- Description: Get active sessions by users other than the current user
|
||||
-- =============================================
|
||||
CREATE PROCEDURE [dbo].[vesp_GetOtherActiveSessions]
|
||||
(
|
||||
@UsrID AS varchar(100)
|
||||
)
|
||||
AS
|
||||
BEGIN
|
||||
|
||||
SELECT
|
||||
[UserID],
|
||||
[DTSDtart],
|
||||
[MachineName]
|
||||
FROM [Sessions]
|
||||
WHERE DTSEnd IS NULL AND UserID != @UsrID
|
||||
|
||||
RETURN
|
||||
END
|
||||
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_GetOtherActiveSessions] Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: [vesp_GetOtherActiveSessions] Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
| ADD New Code Before this Block |
|
||||
@@ -24297,8 +24420,8 @@ BEGIN TRY -- Try Block
|
||||
DECLARE @RevDate varchar(255)
|
||||
DECLARE @RevDescription varchar(255)
|
||||
|
||||
set @RevDate = '09/05/2025 7:00 AM'
|
||||
set @RevDescription = 'Added stored procedure for User Access Control Report'
|
||||
set @RevDate = '09/16/2025 7:00 AM'
|
||||
set @RevDescription = 'Added Purge Change History and Index Maintenance functions to Admin Tools'
|
||||
|
||||
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
|
||||
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
|
||||
|
Reference in New Issue
Block a user