I have a SQL DW table partitioned by month. Our DBA moved on a few months ago and so our tables haven't been partitioned since. We noticed only due to slow down on the tables.
When we attempt to add a partition by using the split function we get the error below
"SPLIT clause of ALTER PARTITION statement failed because the partition is not empty."
We have tried the following
CREATE TABLE [data].[sessions_range]
WITH
(
CLUSTERED COLUMNSTORE INDEX,
DISTRIBUTION = HASH([sesh_id]),
PARTITION
(
-- SAMPLE RANGE
[session_start_dt] RANGE RIGHT FOR VALUES
(
'2016-12-01'
)
)
)
AS
SELECT *
FROM [data].[sessions]
WHERE 1=2
;
ALTER TABLE [data].[sessions] SWITCH PARTITION <guessed at a partition number>
TO [data].[sessions_range] PARTITION 2;
ALTER TABLE [data].[sessions] SPLIT RANGE ('2016-12-01');
Its after the last row there it fails. The Switch partition seems to take ok although we did have to go through the partition numbers until we found the corresponding partition within range.
Can anyone help us as to why the partition would still be saying not empty during the split even after we have switched?