Monday, October 26, 2015

Partition Level Truncation in SQL Server 2016.

Prior to SQL 2016 to clear out a partition, you have to switch data to an auxiliary table (with identical schema) and truncate the auxiliary table. SQL Server 2016 allows you to perform truncation at partition level, eliminating the overhead involved in maintaining auxiliary table.

The syntax is very simple -

TRUNCATE TABLE dbo.FactProductInventoryPartitioned WITH (PARTITIONS (6,7,8) )
This truncates partitions 6,7 & 8 from the fact table.

This greatly simplifies sliding window implementation for DataWarehouse Loads.


No comments: