25 May 2012

Get RowCount all tables of a Database in SqlServer

SELECT [TableName] = O.name, [RowCount] =MAX(I.rows)FROM sysobjects O, sysindexes I
WHERE O.xtype ='U'AND I.id =OBJECT_ID(O.name)
GROUP BY O.name ORDER BY [RowCount] DESC

No comments: