initial commit
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,72 @@
|
||||
IF OBJECT_ID('[dbo].[MaintainHCIChangeTrackingHistory]') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE [dbo].[MaintainHCIChangeTrackingHistory];
|
||||
END
|
||||
GO
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*=============================================================================
|
||||
|
||||
Description
|
||||
----------------------
|
||||
OCTP-2459
|
||||
|
||||
Cleans history data in HCIChangeTracking.
|
||||
Deletes all records older than 2 years in the following tables:
|
||||
* [OlpDirectoryChangeLog]
|
||||
* [OlpfactChangeLog]
|
||||
* [OlpfactValidatorChangeLog]
|
||||
|
||||
Where
|
||||
----------------------
|
||||
On all TriaFact instances
|
||||
|
||||
Dependencies
|
||||
----------------------
|
||||
Called by job [W030100 - Cleanup HCIChangeTracking]
|
||||
|
||||
Creation:
|
||||
03.11.2022 / TSC
|
||||
|
||||
Modifications:
|
||||
|
||||
=============================================================================*/
|
||||
CREATE PROCEDURE dbo.MaintainHCIChangeTrackingHistory
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE
|
||||
@deleted INT
|
||||
,@batch_size INT = 100000
|
||||
,@today DATE = DATEADD(DAY, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP), 0);
|
||||
|
||||
SET @deleted = 1;
|
||||
WHILE @deleted > 0 BEGIN
|
||||
DELETE TOP (@batch_size) cl
|
||||
FROM dbo.[OlpDirectoryChangeLog] cl
|
||||
WHERE cl.CreationDate < DATEADD(YEAR, -2, @today);
|
||||
|
||||
SET @deleted = @@ROWCOUNT;
|
||||
END
|
||||
|
||||
SET @deleted = 1;
|
||||
WHILE @deleted > 0 BEGIN
|
||||
DELETE TOP (@batch_size) cl
|
||||
FROM dbo.[OlpfactChangeLog] cl
|
||||
WHERE cl.CreationDate < DATEADD(YEAR, -2, @today);
|
||||
|
||||
SET @deleted = @@ROWCOUNT;
|
||||
END
|
||||
|
||||
SET @deleted = 1;
|
||||
WHILE @deleted > 0 BEGIN
|
||||
DELETE TOP (@batch_size) cl
|
||||
FROM dbo.[OlpfactValidatorChangeLog] cl
|
||||
WHERE cl.CreationDate < DATEADD(YEAR, -2, @today);
|
||||
|
||||
SET @deleted = @@ROWCOUNT;
|
||||
END
|
||||
END
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# SQL Server Management Studio Solution File, Format Version 18.00
|
||||
VisualStudioVersion = 15.0.28307.421
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{4F2E2C19-372F-40D8-9FA7-9D2138C6997A}") = "OCTPDBA-379 - cleanup hciChangeTracking", "OCTPDBA-379 - cleanup hciChangeTracking.ssmssqlproj", "{0C063DF9-C600-47CB-A702-A09D2B620F0C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Default|Default = Default|Default
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0C063DF9-C600-47CB-A702-A09D2B620F0C}.Default|Default.ActiveCfg = Default
|
||||
{486BAABC-4895-4B4A-B50F-D60324239538}.Default|Default.ActiveCfg = Default
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {21012A30-E112-4401-B134-71314DC7DDAB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0"?>
|
||||
<SqlWorkbenchSqlProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="OCTPDBA-379 - cleanup hciChangeTracking">
|
||||
<Items>
|
||||
<LogicalFolder Name="Connections" Type="2" Sorted="true">
|
||||
<Items>
|
||||
<ConnectionNode Name="swtfdev01.centralinfra.net\DGALTFAC:CENTRALINFRA\ua208700">
|
||||
<Created>2022-11-07T09:17:46.0882714+01:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>swtfdev01.centralinfra.net\DGALTFAC</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
|
||||
</ConnectionNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Queries" Type="0" Sorted="true">
|
||||
<Items>
|
||||
<FileNode Name="MaintainHCIChangeTrackingHistory.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:swtfdev01.centralinfra.net\DGALTFAC:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>swtfdev01.centralinfra.net\DGALTFAC</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>MaintainHCIChangeTrackingHistory.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="W030100 - Cleanup HCIChangeTracking.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:swtfdev01.centralinfra.net\DGALTFAC:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>swtfdev01.centralinfra.net\DGALTFAC</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>W030100 - Cleanup HCIChangeTracking.sql</FullPath>
|
||||
</FileNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Miscellaneous" Type="3" Sorted="true">
|
||||
<Items />
|
||||
</LogicalFolder>
|
||||
</Items>
|
||||
</SqlWorkbenchSqlProject>
|
||||
Binary file not shown.
Reference in New Issue
Block a user