Advertisements
Truncate
Truncate partition will truncate the partition and leave as empty then we can merge it.
MSDN: Specifies the partitions to truncate or from which all rows are removed. If the table isn’t partitioned, the WITH PARTITIONS argument generates an error. If the WITH PARTITIONS clause isn’t provided, the entire table is truncated.
Test Code:
Use the same script used in part 1 for creating database and table.
-- delete b/w 1 to 6 TRUNCATE TABLE [tbl_partition_test] WITH (PARTITIONS (2 TO 5)); GO -- delete only 3,5 & 6 TRUNCATE TABLE [tbl_partition_test] WITH (PARTITIONS (3,5,6)) -- delete only 4 TRUNCATE TABLE [tbl_partition_test] WITH (PARTITIONS (4)); -- The truncate partition no or range partition no will remove all data from the partition make sure you take backup by switch out -- if you really do not want the data you can truncate the partition