Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Top 20 tables in a Database along with Schema

Author  Topic 

vijay1234
Starting Member

48 Posts

Posted - 2014-09-02 : 03:01:22
Hi Friends,

I would need a query for respective DB to find the list of top 20 tables along with schema.

Below query is not giving me the schema, since i have not used systables.

select top 20 object_name(id) as tablename,rowcnt as [no of records]
from sysindexes where indid in (0,1) order by rowcnt desc

Kindly provide me the query which will give the schema name as well before the tablename dear friends.

Thanks much in advance.

Regards,
Vijay

stepson
Aged Yak Warrior

545 Posts

Posted - 2014-09-02 : 03:15:01
[code]
select top 20
Object_Schema_name(id) as SchemaName
,object_name(id) as tablename
,rowcnt as [no of records]
from sysindexes AS SI
where indid in (0,1)
order by rowcnt desc
[/code]


sabinWeb MCP
Go to Top of Page

vijay1234
Starting Member

48 Posts

Posted - 2014-09-02 : 08:44:21
Thankyou Mate :)
Go to Top of Page
   

- Advertisement -