I need to significantly reduce the size of a Kentico 7 database. Looking at the tables using the query below (source), I can see that some of the largest tables in terms of data size are CMS_AttachmentHistory and CMS_VersionHistory:
CREATE TABLE #tmpTableSizes
(
tableName varchar(100),
numberofRows varchar(100),
reservedSize varchar(50),
dataSize varchar(50),
indexSize varchar(50),
unusedSize varchar(50)
)
insert #tmpTableSizes
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
select * from #tmpTableSizes
order by cast(LEFT(reservedSize, LEN(reservedSize) - 4) as int) desc
I found a forum post from 2013 that implies it is ok to simply set the AttachmentBinary column to null in the CMS_AttachmentHistory table.
I don't know that there is a similar possibility in the CMS_VersionHistory table.
Simply truncating the tables doesn't work due to FK constraints, so I'm hesitant to go further along that route.
Is there a better way to do this other than a SQL TRUNCATE statement?