This script requires the creation of the big view in
http://www.sqlservercentral.com/scripts/Partitioning/73324/
Works with heap, clustered index, compressed tables
It is similar functionality as
http://www.sqlservercentral.com/scripts/Truncate+Table/69506/
But it is a bit more powerful and flexible
1) Create an empty DEST_TABLE identical to SOURCE_TABLE
exec dbo.sp_truncate_partitions 'COPYTABLE', 'SOURCE_TABLE' , 'DEST_TABLE', null,null
This table can be used, for example, as stage table during an ETL process.
2) Like 1 , then switch the partitions from '2013-01-01' up to '2013-02-02' to DEST_TABLE
exec dbo.sp_truncate_partitions 'SWITCH', 'DIM_CONTRACT_SIM_SERIAL' , 'tmp_DIM_CONTRACT_SIM_SERIAL_ZZZ', '2013-01-01', '2013-02-02'
3) The same as 2 , then drops DEST_TABLE
exec dbo.sp_truncate_partitions 'DELETE', 'DIM_CONTRACT_SIM_SERIAL' , 'tmp_DIM_CONTRACT_SIM_SERIAL_ZZZ', '2013-01-01', '2013-02-02'