Here is the sample partition function and schema. I have included my requirement to change the file group "Need to Change FG"
After merging the partition function and deleting all the RANGE which was mapped wrong below is the partition function.
Partition_Function
CREATE PARTITION FUNCTION [pf_EventData](datetime) AS RANGE LEFT FOR VALUES (N'2012-01-01T00:00:00.000',N'2019-11-01T00:00:00.000', N'2019-12-01T00:00:00.000', N'2020-01-01T00:00:00.000', N'2029-01-01T00:00:00.000')
GO
Partition Schema
CREATE PARTITION SCHEME [ps_EventData] AS PARTITION [pf_RtEvents] TO ([BigTable_Empty], [BigTable1911], [BigTable1912], [BigTable_DEFAULT], [BigTable_DEFAULT], [BigTable_DEFAULT], [BigTable_DEFAULT], [BigTable_DEFAULT], [BigTable_DEFAULT], [BigTable_DEFAULT],
[BigTable_DEFAULT], [BigTable2008], [BigTable_DEFAULT], [BigTable_DEFAULT], [BigTable_DEFAULT], [BigTable_DEFAULT], [BigTable_DEFAULT], [BigTable_DEFAULT])
GO
Schema.Table | Index ID | Structure | Index | Rows | In-Row GB | LOB GB | Partition # | Partition Function | Boundary Type | Boundary Point | Filegroup | Need to Change this |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 215171 | 0.030464172 | 0 | 100 | pf_EventData | Left / Upper | NULL | BigTable_DEFAULT | BigTable_DEFAULT |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 16619 | 0.002388 | 0 | 99 | pf_EventData | Left / Upper | 1/1/2029 0:00 | BigTable_DEFAULT | BigTable_2029 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 0 | 0 | 0 | 98 | pf_EventData | Left / Upper | 1/1/2021 0:00 | BigTable_DEFAULT | BigTable_2012 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 0 | 0 | 0 | 97 | pf_EventData | Left / Upper | 12/1/2020 0:00 | BigTable_DEFAULT | BigTable_2011 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 0 | 0 | 0 | 96 | pf_EventData | Left / Upper | 11/1/2020 0:00 | BigTable_DEFAULT | BigTable_2010 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 0 | 0 | 0 | 95 | pf_EventData | Left / Upper | 10/1/2020 0:00 | BigTable2008 | BigTable_2009 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 0 | 0 | 0 | 94 | pf_EventData | Left / Upper | 9/1/2020 0:00 | BigTable_DEFAULT | BigTable_2008 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 0 | 0 | 0 | 93 | pf_EventData | Left / Upper | 8/1/2020 0:00 | BigTable_DEFAULT | BigTable_2007 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 0 | 0 | 0 | 92 | pf_EventData | Left / Upper | 7/1/2020 0:00 | BigTable_DEFAULT | BigTable_2006 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 0 | 0 | 0 | 91 | pf_EventData | Left / Upper | 6/1/2020 0:00 | BigTable_DEFAULT | BigTable_2005 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 0 | 0 | 0 | 90 | pf_EventData | Left / Upper | 5/1/2020 0:00 | BigTable_DEFAULT | BigTable_2004 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 0 | 0 | 0 | 89 | pf_EventData | Left / Upper | 4/1/2020 0:00 | BigTable_DEFAULT | BigTable_2003 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 0 | 0 | 0 | 88 | pf_EventData | Left / Upper | 3/1/2020 0:00 | BigTable_DEFAULT | BigTable_2002 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 0 | 0 | 0 | 87 | pf_EventData | Left / Upper | 2/1/2020 0:00 | BigTable_DEFAULT | BigTable_2001 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 50000 | 380.3596039 | 0 | 86 | pf_EventData | Left / Upper | 1/1/2020 0:00 | BigTable1912 |
dbo.BigTable | 1 | CLUSTERED | PK_BigTable | 20000 | 396.7081375 | 0 | 85 | pf_EventData | Left / Upper | 12/1/2019 0:00 | BigTable1911 |
Here is what I am expecting
Partition_Function
CREATE PARTITION FUNCTION [pf_EventData](datetime) AS RANGE LEFT FOR VALUES (N'2012-01-01T00:00:00.000',N'2019-11-01T00:00:00.000', N'2019-12-01T00:00:00.000', N'2020-01-01T00:00:00.000', N'2020-02-01T00:00:00.000', N'2020-03-01T00:00:00.000', N'2020-04-01T00:00:00.000',
N'2020-05-01T00:00:00.000', N'2020-06-01T00:00:00.000', N'2020-07-01T00:00:00.000', N'2020-08-01T00:00:00.000', N'2020-09-01T00:00:00.000', N'2020-10-01T00:00:00.000', N'2020-11-01T00:00:00.000', N'2020-12-01T00:00:00.000', N'2021-01-01T00:00:00.000', N'2029-01-01T00:00:00.000')
GO
Partition Schema
CREATE PARTITION SCHEME [ps_EventData] AS PARTITION [pf_RtEvents] TO ([BigTable1911], [BigTable1912], [BigTable2001], [BigTable2002], [BigTable2003], [BigTable2004], [BigTable2005], [BigTable2006], [BigTable2007], [BigTable2008], [BigTable2009], [BigTable2010],
[BigTable2011], [BigTable2012], [BigTable_2101], [BigTable_DEFAULT])
GO
After removing the RANGE from partition how to modify the partition schema to add the range to another File group instead of BigTable_DEFAULT
Thanks a lot in advance.
Please click "Mark as Answer" if the post solves your problem - Thanks