📜  从数据库中获取所有表记录计数的 SQL 查询 - SQL 代码示例

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

代码示例1
DECLARE @TableRowCounts TABLE ([TableName] VARCHAR(128), [RowCount] INT) ;
INSERT INTO @TableRowCounts ([TableName], [RowCount])
EXEC sp_MSforeachtable 'SELECT ''?'' [TableName], COUNT(*) [RowCount] FROM ?' ;
SELECT [TableName], [RowCount]
FROM @TableRowCounts
ORDER BY [TableName]
GO