Skip to content

Instantly share code, notes, and snippets.

@adnanzameer
Last active May 1, 2019 21:36
Show Gist options
  • Save adnanzameer/f4305a18641b9652aeed907079f6cecd to your computer and use it in GitHub Desktop.
Save adnanzameer/f4305a18641b9652aeed907079f6cecd to your computer and use it in GitHub Desktop.
SQL script to delete unpublished single version content from Episerver
DECLARE @pkid int
DECLARE db_cursor CURSOR FOR select distinct fkPageID from tblWorkpage where HasBeenPublished= 0 Group by fkpageid having count(fkPageID) = 1
declare @isLeafNode int
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @pkid
WHILE @@FETCH_STATUS = 0
BEGIN
select @isLeafNode = IsLeafNode from tblContent where pkID=@pkid
if(@isLeafNode = 1)
Begin
EXEC [dbo].editDeletePage @PageID = @pkid, @ForceDelete = 1
End
FETCH NEXT FROM db_cursor INTO @pkid
END
CLOSE db_cursor
DEALLOCATE db_cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment