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
 General SQL Server Forums
 New to SQL Server Programming
 Which tables are populated

Author  Topic 

GavinD1977
Yak Posting Veteran

83 Posts

Posted - 2007-05-10 : 04:27:16
Hello all.

I have a database with literally hundereds of tables in it. Can anyone advise me of how to tell which ones are populated with data and which ones arent?

Thanks people

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2007-05-10 : 04:31:41
[code]
SELECT o.[name], i.rowcnt
FROM sysobjects o
LEFT OUTER JOIN sysindexes i
ON o.[id] = i.[id]
WHERE o.xtype = 'U' AND i.indid < 2 And i.RowCnt > 0


[/code]

Before you use the above code, make sure you read this link

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=35565&SearchTerms=sysindexes

Chirag

http://chirikworld.blogspot.com/
Go to Top of Page

GavinD1977
Yak Posting Veteran

83 Posts

Posted - 2007-05-10 : 04:42:06
Thats great!

Thanks very much for the swift response. Much appreciated.

Go to Top of Page
   

- Advertisement -