【问题标题】:SQL - How to get total number of partitions of table via codeSQL - 如何通过代码获取表的分区总数
【发布时间】:2022-01-04 03:36:16
【问题描述】:

我正在尝试找到一种方法来获取表上的分区总数,但我无法通过代码执行此操作。

我知道我可以通过 Table Properties > Storage 查看值

有没有办法通过代码得到这个?

【问题讨论】:

    标签: sql ssms


    【解决方案1】:

    此信息来自sys.dm_db_partition_stats

    SELECT  
        MAX(PS.partition_number) AS PartitionCount
    FROM
        sys.dm_db_partition_stats PS
    WHERE
        PS.index_id = 1 --The parttion scheme is using a Clustered Index
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-18
      • 2011-04-01
      • 1970-01-01
      • 2023-03-21
      相关资源
      最近更新 更多