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.
Author |
Topic |
Clages1
Yak Posting Veteran
69 Posts |
Posted - 2007-06-27 : 09:46:09
|
Hiusing exec sp_spaceused AREAI get this where 20 is number of RowsArea 20 40 KB 16 KB 24 KB 0 KBUsing select TABLE_NAMEfrom INFORMATION_SCHEMA.TABLES aWHERE TABLE_TYPE = 'BASE TABLE'I get all table names from a DATABASEI would like to get something like thisTableName Qty Of Rowsaaaaaaa 123bbbbbbb 422 ccccccc 555etcHow can i do this?In other words i would like to know what tables are emptys andwhat arent.TksC.lages |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-06-27 : 10:00:10
|
exec sp_MSForEachTable 'select ''?'' as TableName, count(*) as RowCnt from ?'_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-27 : 10:27:34
|
orDBCC Updateusage Select object_name(id) as table_name, rows from sysindexeswhere indid<2order by object_name(id)MadhivananFailing to plan is Planning to fail |
|
|
Clages1
Yak Posting Veteran
69 Posts |
Posted - 2007-06-27 : 17:58:18
|
TksI did not Know this SPbut i have used your ideia and fix to my needstksCarlos Lagesuse pubsgo create table #rowcount (tablename varchar(128), rowcnt int)exec sp_MSforeachtable 'insert into #rowcount select ''?'', count(*) from ?'select top 5 * from #rowcount order by tablenamedrop table #rowcount |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-06-28 : 05:30:53
|
sp_MSforeachtable is an undocumentde stored procedure and is not recommended in production use.you have no support for it if something goes wrong._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-28 : 06:13:26
|
Also try the method I suggestedMadhivananFailing to plan is Planning to fail |
|
|
|
|
|