$PARTITION
返回指定的分区函数的分区号
CREATE PARTITION FUNCTION RangePF1 ( INT ) AS RANGE FOR VALUES (10, 100, 1000) ; GO SELECT $PARTITION.RangePF1 (10) ; GO
结果
获取分区表的每个非空分区的行数,例子
SELECT $PARTITION.TransactionRangePF1(TransactionDate) AS Partition, COUNT(*) AS [COUNT] FROM Production.TransactionHistory GROUP BY $PARTITION.TransactionRangePF1(TransactionDate) ORDER BY Partition ; GO
也可以作为筛选条件
SELECT * FROM Production.TransactionHistory WHERE $PARTITION.TransactionRangePF1(TransactionDate) = 5 ;