统计sql server 2012表的行数

--功能:统计sql server 2012表的行数
SELECT a.name,
a.object_id,
b.rows,
b.index_id
FROM sys.tables AS a
INNER JOIN sys.partitions AS b
ON a.object_id = b.object_id
WHERE b.index_id IN ( 0, 1 );

sys.partitions系统视图:https://docs.microsoft.com/zh-cn/sql/relational-databases/system-catalog-views/sys-partitions-transact-sql?view=sql-server-2017

sys.tables系统视图:https://docs.microsoft.com/zh-cn/sql/relational-databases/system-catalog-views/sys-tables-transact-sql?view=sql-server-2017

--第二种方法

 SELECT OBJECT_NAME(object_id) AS object_name,
rows
FROM sys.partitions
WHERE index_id IN ( 0, 1 )
AND object_id IN (
SELECT object_id FROM sys.tables
);
上一篇:使用Nginx做图片服务器时候,配置之后图片访问一直是 404问题解决


下一篇:js判断手机端操作系统的两种方法