Sharepoint gathers usage and health data to database called WSS_Logging.
By Default retention period is 14 days.
If You want to make it lower, lets say 2 days use the below oneliner for it.
1 |
Get-SPUsageDefinition | Set-SPUsageDefinition -DaysRetained 2 |
And then just a quick hint for releasing space from Sharepoint WSS_Logging database.
Use the query below to truncate db and free used space.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
DECLARE @TableName AS VARCHAR(MAX) DECLARE table_cursor CURSOR FOR SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME LIKE '%_Partition%' OPEN table_cursor FETCH NEXT FROM table_cursor INTO @TableName WHILE @@FETCH_STATUS = 0 BEGIN DECLARE @SQLText AS NVARCHAR(4000) SET @SQLText = 'TRUNCATE TABLE ' + @TableName EXEC sp_executeSQL @SQLText FETCH NEXT FROM table_cursor INTO @TableName END CLOSE table_cursor DEALLOCATE table_cursor |