📜  sql server 计算所有表的行数 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:04:57.552000             🧑  作者: Mango

代码示例1
CREATE TABLE #counts
(
    table_name varchar(255),
    row_count int
)

EXEC sp_MSForEachTable @command1='INSERT #counts (table_name, row_count) SELECT ''?'', COUNT(*) FROM ?'
SELECT table_name, row_count FROM #counts ORDER BY table_name, row_count DESC
DROP TABLE #counts