• SQL Server中查看所有表RowCount最高效的SQL


    -- Shows all user tables and row counts for the current database

    -- Remove OBJECTPROPERTY function call to include system objects

    SELECT o.NAME,

    i.rowcnt

    FROM sysindexes AS i

    INNER JOIN sysobjects AS o ON i.id = o.id

    WHERE i.indid < 2

    AND OBJECTPROPERTY(o.id, 'IsMSShipped') = 0

    ORDER BY o.NAME

    注意:

    sysindexes这个系统表会在将来的SQL Server中删除,所以建议SQL 2005和2008使用下面的DMV代替:

    -- Shows all user tables and row counts for the current database

    -- Remove is_ms_shipped = 0 check to include system objects

    -- i.index_id < 2 indicates clustered index (1) or hash table (0)

    SELECT o.name,

    ddps.row_count

    FROM sys.indexes AS i

    INNER JOIN sys.objects AS o ON i.OBJECT_ID = o.OBJECT_ID

    INNER JOIN sys.dm_db_partition_stats AS ddps ON i.OBJECT_ID = ddps.OBJECT_ID

    AND i.index_id = ddps.index_id

    WHERE i.index_id < 2

    AND o.is_ms_shipped = 0

    ORDER BY o.NAME

  • 相关阅读:
    面向对象编程-介绍(python3入门)
    课堂作业03
    软件工程个人作业04
    团队介绍
    学习进度条
    课堂作业02
    学习进度条
    软件工程个人作业03
    课堂作业01
    软件工程个人作业02
  • 原文地址:https://www.cnblogs.com/rockniu/p/1559306.html
Copyright © 2020-2023  润新知