我的方法是:
第一步:创建分区函数、分区方案
第二步:临时对分区表创建一个非聚簇索引(之所以选择非聚簇索引是因为这样不需要对物理节点进行排序,缩短时间,也可以创建聚簇索引),在创建索引的同时应用分区方案
第三步:删除索引(分区方案依然还在)
--创建数据表 CREATE TABLE [dbo].[BizUser]( [ID] [bigint] IDENTITY(1,1) NOT NULL, [Uid] [bigint] NOT NULL, [Status] [char](1) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT ('1'), [UserType] [int] NOT NULL DEFAULT ((1)), [RankNo] [bigint] NOT NULL DEFAULT ((0)), [CreatedTime] [datetime] NOT NULL DEFAULT (getdate()), [BizId] [varchar](16) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT (''), [OSId] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL DEFAULT (''), CONSTRAINT [PK_BizUser] PRIMARY KEY NONCLUSTERED ( [ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) GO
CREATE CLUSTERED INDEX IND_UnPartitionBizUser_CreatedTime ON dbo.UnPartitionBizUser ( CreatedTime ASC ) ON Sch_BizUser_CreatedTime(CreatedTime) --Sch_BizUser_CreatedTime是分区方案
DROP INDEX UnPartitionBizUser.IND_UnPartitionBizUser_CreatedTime
SELECT partition_id, object_id, partition_number, rows FROM sys.partitions WHERE object_id = OBJECT_ID('UnPartitionBizUser')