Home Count tables in database have more than one record in SQL Server
Reply: 1

Count tables in database have more than one record in SQL Server

Waleed Ali
1#
Waleed Ali Published in 2018-02-12 14:43:17Z

Is there any query which return count of the tables having record more than one row?

uzi
2#
uzi Reply to 2018-02-12 14:56:52Z

One way:

select
    TableName = sc.name +'.'+ ta.name, RowCnt = sum(pa.rows) 
from 
    sys.tables ta
    join sys.partitions pa on pa.object_id = ta.object_id
    join sys.schemas sc on ta.schema_id = sc.schema_id
where 
    ta.is_ms_shipped = 0 
    AND pa.index_id IN (1,0)
group by sc.name,ta.name
having sum(pa.rows) > 0
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 1.703755 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO