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
 rowcount, rowsize

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..sysdatabases



open a

fetch a into @db

while @@fetch_status = 0

begin
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 b



fetch next from a into @db
end

close a
deallocate a


=============================
http://www.sqlserverstudy.com

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-05 : 15:59:19
Here is a start
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=88440&SearchTerms=billing



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -