I am trying and partitioning to an existing SQL Server Graph table (node). The table is very large and is taking long time for deletes etc, so hoping to use partitioning to improve the performance.
However, when I add partition and try to SWITCH the data. It fails with the below error:
Msg 7733, Level 16, State 4, Line 1 'ALTER TABLE SWITCH' statement failed. The table tempdatabase.dbo.graphtable is partitioned while index 'GRAPH_UNIQUE_INDEX_xxxxxxxxx' is not partitioned.
As the index GRAPH_UNIQUE_INDEX_xxxxxxxxx is automatically created, not able to add the partition key it.
CREATE PARTITION FUNCTION f_partfunction (INT) AS RANGE LEFT
FOR VALUES (1,100,200,300)
GO
-- Create the partition scheme
CREATE PARTITION SCHEME s_partscheme
AS PARTITION f_partfunction
ALL TO ([PRIMARY]);
GO
CREATE TABLE [dbo].[graphtable](
PartitionKey INT,
ID INT,
EName varchar(100))
AS NODE ON s_partscheme (PartitionKey)
go
CREATE TABLE [dbo].[graphtable_test](
PartitionKey INT,
ID INT,
EName varchar(100))
go
--Failing Code
ALTER TABLE [dbo].[graphtable] SWITCH PARTITION 3 TO [dbo].[graphtable_test]