Montag, 31. Mai 2010

Determine the rowcounts for all tables of a SQL-Server Database

Of course you can loop through all tables of a database, compose a select statement to query count(*) of each single table and end in some time-out problem at some customer database. 
There is a quick solution without any loops:

SELECT o.name, max(i.rows) FROM dbo.sysindexes i  join sysobjects o on i.id = o.id
group by o.id, o.name
order by 1
 I'm not 100 % certain that the results are exact in all cases, but for me it works well.

Cf. http://entwickler-forum.de/showthread.php?t=18850

Keine Kommentare:

Kommentar veröffentlichen