Skip to content

Instantly share code, notes, and snippets.

@AaronSadlerUK
Created March 25, 2024 20:23
Show Gist options
  • Save AaronSadlerUK/ab3a51647f3755b8b8f84b7bec25e91e to your computer and use it in GitHub Desktop.
Save AaronSadlerUK/ab3a51647f3755b8b8f84b7bec25e91e to your computer and use it in GitHub Desktop.
DECLARE @AlterStatements TABLE (
Statement NVARCHAR(MAX)
)
INSERT INTO @AlterStatements (Statement)
SELECT 'ALTER INDEX [' + I.name + '] ON [' + T.name + '] REBUILD'
FROM sys.indexes I
INNER JOIN sys.tables T ON I.object_id = T.object_id
WHERE I.type_desc = 'NONCLUSTERED'
AND I.name IS NOT NULL
DECLARE @Statement NVARCHAR(MAX)
DECLARE AlterCursor CURSOR FOR
SELECT Statement FROM @AlterStatements
OPEN AlterCursor
FETCH NEXT FROM AlterCursor INTO @Statement
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC sp_executesql @Statement
FETCH NEXT FROM AlterCursor INTO @Statement
END
CLOSE AlterCursor
DEALLOCATE AlterCursor
drop table [dbo].[umbracoContentVersionCleanupPolicy]
GO
--drop table umbracoContentVersionCleanupPolicy
CREATE TABLE [dbo].[umbracoContentVersionCleanupPolicy](
[contentTypeId] [int] NOT NULL,
[preventCleanup] [bit] NOT NULL,
[keepAllVersionsNewerThanDays] [int] NULL,
[keepLatestVersionPerDayForDays] [int] NULL,
[updated] [datetime] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[umbracoContentVersionCleanupPolicy] WITH NOCHECK ADD CONSTRAINT [FK_umbracoContentVersionCleanupPolicy_cmsContentType_nodeId] CHECK (([contentTypeId]<>''))
GO
ALTER TABLE [dbo].[umbracoContentVersionCleanupPolicy] CHECK CONSTRAINT [FK_umbracoContentVersionCleanupPolicy_cmsContentType_nodeId]
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment