sql 删除Umbraco中的旧版本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 删除Umbraco中的旧版本相关的知识,希望对你有一定的参考价值。

/* Delete Old Document Versions */

Declare @keepOldVersionsCount int, @keepNewerThanDate datetime

Set @keepOldVersionsCount = 0 /* 0 Keeps published and newest only. */
Set @keepNewerThanDate = getdate() /* getDate() or '2013-01-01' */

IF OBJECT_ID('tempdb..#versions') IS NOT NULL DROP TABLE #versions

SELECT VersionID, nodeId, updateDate, newest, published  INTO #versions 
FROM cmsDocument
WHERE versionID NOT IN 
	(SELECT D.versionId 
	 FROM cmsDocument D 
	 WHERE D.versionId IN 
		(SELECT versionId 
		 FROM 
			(SELECT CV.versionId, published, newest, CV.versionDate, RANK() OVER(ORDER BY CV.versionDate DESC) RowNum   
             FROM cmsContentVersion CV JOIN cmsDocument DD ON CV.versionId = DD.versionId    
             WHERE DD.nodeId = D.nodeId) AS tmp     
		 WHERE tmp.RowNum <= (@keepOldVersionsCount + 2) OR tmp.published = 1 OR tmp.newest = 1 or tmp.versionDate >= @keepNewerThanDate)  
	 )
                                   
Select * from #versions

--DELETE FROM cmsContentVersion WHERE VersionId IN (select #versions.VersionId from #versions)
--DELETE FROM cmsPreviewXml WHERE versionId IN (select #versions.VersionId from #versions)
--DELETE FROM cmsPropertyData WHERE VersionId IN (select #versions.VersionId from #versions)
--DELETE FROM cmsDocument WHERE VersionId IN (select #versions.VersionId from #versions)
 
 

以上是关于sql 删除Umbraco中的旧版本的主要内容,如果未能解决你的问题,请参考以下文章

sql Umbraco - 删除所有内容的版本历史记录

sql 按Umbraco中的文档类型删除所有节点

sql 按Umbraco中的文档类型删除所有节点

无法删除 esky 0.9.8 中的旧版本:Python

Umbraco 从 SQL Server 2012 迁移到 SQL Server 2008 R2

Squirrel SQL 使用 Java.exe 的旧路径