I have a table 'X' and did the following
this 3 steps created 4 logical partitions of the data I had.
My question is, how do I revert this partitioning to its original state ?
After 2 days of continuous searching
The Steps:
DROP INDEX CIDX_X on X
/* drop the clustered */CREATE CLUSTERED INDEX CIDX_X1 ON X(col1) ON [PRIMARY]
/* Create another clustered index on the table to free it from the partitioning scheme; Here, the "ON [primary]" part is key to removing the partition scheme from the table ! */DROP PARTITION SCHEME PS1
DROP PARTITION FUNCTION PF1
DROP INDEX CIDX_X1 ON X
/* drop the dummy clustered index you created, as it was only created to free the table from the partitioning scheme */I found that some additional steps should be added to the answer given by Storm, since, there are some points like ... before deleting the clustered index, the publication needs to be dropped because it wont allow the clustered index to get dropped before that and after dropping those partition-scheme and partition function needs to be recreated, and publication also again needs to be started.
Note: I am using SQL 2012
Primary key is normally the most commonly used clustered constraint, so wherever i used primary key, consider that those steps also apply to Clustered constraints too. Also, PS= Partition Scheme, PF = Partition Function.
Some preparatory steps:
All the above, using SQL Management Studio "generate scripts" upon right click. And choose drop and create.
Now, when everything is ready.
1. Drop the publication (use the script that you generated)
2. Drop the Primary key constraint of those tables which are linked with the PS.
alter table [tablename] drop constraint [pk_name]
3. Make a dummy constraint but use the same fields that you used in that deleted primary key. CREATE CLUSTERED INDEX CIDX_X1 ON tablename(field1,field2,field3,field4) ON [PRIMARY]
4. drop the partition scheme and function.
DROP PARTITION SCHEME [PartitionSchemeName_PS]
GO
DROP PARTITION FUNCTION [PartitionfunctionName_PF]
GO
DROP INDEX CIDX_X1 ON tablename
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With