IF OBJECT_ID('tempdb..#T','U') IS NOT NULL DROP TABLE #T
GO
CREATE TABLE #T (TableName nvarchar(500),NumberOfRows int)
GO
INSERT INTO #T
EXEC sp_msForEachTable 'SELECT PARSENAME(''?'', 1) as TableName,COUNT(*) as NumberOfRows FROM ?'
GO
SELECT * FROM #T ORDER BY NumberOfRows DESC
No comments:
Post a Comment