I have implemented partitioning for a particular table, in such a way that user can partition min 1 and max upto 52, to a particular table for a particular year.
Now, after performing partitioning, I want to undo that. So what I am doing is executing following four statements inside while loop, execute them as many times as the count of partition:
ALTER PARTITION FUNCTION TablePF() MERGE RANGE ('2016-01-01') ALTER PARTITION SCHEME TablePS NEXT USED [PRIMARY] ALTER DATABASE TestDB REMOVE FILE TestDBF ALTER DATABASE TestDB REMOVE FILEGROUP TestDBF
Inside while loop, each time I am putting the correct value of date, file name and filegroup name, but I am not changing the [PRIMARY] filegroup for the partition scheme. I am able to undo the partitioning.
I just want to confirm whether I am doing the correct thing by providing [PRIMARY] filegroup for the partition scheme in above statement#2. Please Suggest.