Hi,
The solution is simply to create a partitioned table with the same structure using CTAS statement -> DROP the old table -> Rename the new table to have the old name
CREATE TABLE [dbo].[T]
(
ID int NOT NULL
, Txt nvarchar(20) NOT NULL
)
WITH (DISTRIBUTION = HASH(ID))
GO
INSERT T(ID, Txt) VALUES (1,'Ronen')
INSERT T(ID, Txt) VALUES (2,'Ariely')
INSERT T(ID, Txt) VALUES (2000,'Ariely')
GO
SELECT * FROM T
GO
------------------------------------------
-- Step 1: Create a partitioned table with the same structure using CTAS statement
CREATE TABLE dbo.T1
WITH (
DISTRIBUTION = HASH(ID),
CLUSTERED COLUMNSTORE INDEX,
PARTITION ([ID] RANGE LEFT FOR VALUES(222)))
AS
SELECT * FROM T
GO
-- Step 2: Confirm the data in the new table
SELECT * FROM T1
GO
-- Step 3: Drop old table and rename new table
DROP TABLE T
GO
RENAME OBJECT T1 TO T;
GO
------------------------------------------ All is ready!
SELECT * FROM T
GO
------------------------------------------
-- Clean the table
DROP TABLE T
GO