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 |
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2007-09-05 : 15:39:54
|
| Trying to get the rowcount, rowsize for every table in everydatabase?I'm getting the same tables from the same db. anyone ideas how to fix it?declare @db varchar(40)declare @sql varchar(8000)declare @cursor varchar(8000)declare @table_name varchar(60)declare a cursor for select name from master..sysdatabasesopen afetch a into @dbwhile @@fetch_status = 0begin print '' set @sql = 'use [' + @db + ']' print @sql exec (@sql) declare b cursor for select table_name from information_schema.tables where table_type = 'base table' and table_schema = 'dbo' and table_name not like 'dbo.%' open b fetch next from b into @table_name while @@fetch_status = 0 begin select @cursor = 'exec sp_spaceused ' + '[' + @table_name + ']' print @cursor -- exec (@cursor) fetch next from b into @table_name end close b deallocate bfetch next from a into @dbendclose adeallocate a=============================http://www.sqlserverstudy.com |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|