I have created four partitions in SQL Server using the following functions.
CREATE PARTITION FUNCTION fnYearsRT(DateTime)
AS RANGE RIGHT FOR VALUES
('01/01/2005', '01/01/2006', '01/01/2007', '01/01/2008');
CREATE PARTITION SCHEME date_partscheme
AS PARTITION fnYearsRT
TO (Filegroup1, Filegroup2, Filegroup3, Filegroup4,Filegroup5)
CREATE TABLE Sales.ReturnsArchive
(
ReturnID int IDENTITY NOT NULL,
ProductID int NOT NULL,
CustomerID int NOT NULL,
ReturnDate datetime NOT NULL,
ReturnReason char(20) NULL
)
ON date_partscheme (ReturnDate)
After inserting data I have the following stats
Partition COUNT
2 5151
3 19353
4 51237
5 45576
I want to merge partition 2 and 3 but I am unable to decide which range I should give in merge function.
You actually have 5 partition, not 4, the first one just appears to be empty. To merge partition 2 and 3 use the following code:
This will give you the following ranges: