Reterving all Tables Names and Row Count in SQL

  1. SELECT sc.name +'.'+ ta.name TableName,SUM(pa.rows) RowCnt  
  2. FROM sys.tables ta INNER JOIN sys.partitions pa  
  3. ON pa.OBJECT_ID = ta.OBJECT_ID INNER JOIN sys.schemas sc  
  4. ON ta.schema_id = sc.schema_id  
  5. WHERE ta.is_ms_shipped = 0 AND pa.index_id IN (1,0)  
  6. GROUP BY sc.name,ta.name  
  7. ORDER BY SUM(pa.rowsdesc