1、首先找出文件组对应的分区号
- USE [db]
- GO
- --待分拆文件组
- select fg.name
- ,sp.destination_id
- from sys.destination_data_spaces sp
- inner join sys.partition_schemes scm on sp.partition_scheme_id = scm.data_space_id
- inner join sys.filegroups fg on fg.data_space_id = sp.data_space_id
- where scm.name='分区方案'
- and fg.name='文件组逻辑名称';
2、根据分区号获取记录数
SELECT COUNT(*) FROM [分区表] WHERE $partition.分区函数(分区依据列) = 分区号