Tuesday, August 17, 2010

SQLSERVER中统计所有表的记录数

Create TABLE #temp (TableName VARCHAR (255), RowCnt INT)
EXEC sp_MSforeachtable 'Insert INTO #temp Select ''?'', COUNT(*) FROM ?'
Select TableName, RowCnt FROM #temp ORDER BY TableName
Drop TABLE #temp

No comments: