Remove Partition in SQL Server

If you try to drop either the partition schema or the function you will get errors like these:
- The partition scheme "XXXXXXXXXXXXX" is currently being used to partition one or more tables.
- Partition function 'YYYYYYY' is being used by one or more partition schemes.
As documented in BOL:
- A partition scheme can be dropped only if there are no tables or indexes using the partition scheme.
- A partition function can be dropped only if there are no partition schemes using the partition function.
So the correct way to drop or rebuild the partitioning is:
1. Remove the partitioning:
2. Drop the current clustered index of the Partitioned Table.
    **Indexes were not visible through SSMS, but sp_help ‘tablename’ revealed a number of  
        additional indexes, which were based on the partition scheme.
3. Create a new clustered index that will not use the partition scheme.
4. DROP the PARTITION SCHEMA.
5. Then DROP the PARTITION FUNCTION.
This an approach to removing the partitioning.

Comments