You are here:   Home > Blog
Register   |  Login

Captured Technology - Blog

Minimize

Getting a List of SQL Database Tables with One Statement

by Steve Patterson on Monday, March 23, 2009 8:31 PM

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

Author
Steve Patterson

Latest technology news.

3 comment(s) so far...

Anonymous 3/29/2009

Thanks for the info.

 
Anonymous 4/9/2009

I like the cod every much as my cms software allows for sql statement execution and I forget the names of tables and columns at times.netflix free 14 day trail

 
Anonymous 10/22/2012

Hmmm, I have never tried the SQL statement you have shared. I was looking for some simple query, but the query you have shared seems complex.<br /><br />---------<br />We are a software testing company find us at http://www.kualitatem.com

Translate

Minimize

Sponsors

   Minimize

Categories

Minimize

u comment, i follow