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 2005 Forums
 Transact-SQL (2005)
 Get Database Size across other Servers.

Author  Topic 

craig79
Starting Member

33 Posts

Posted - 2009-03-04 : 01:49:07

I just wanted to know is it a good idea to use a cursor within a cursor to get the database sizes across several servers.

heavymind
Posting Yak Master

115 Posts

Posted - 2009-03-04 : 06:34:36
I don't understand why you need a cursor on the server to get the databases' sizes...
select from sys.master_files and group by database (or use other system views) and you will see all dbs and their sizes in a single statement.

Thanks, Vadym
MCITP DBA 2005/2008
Chief DBA at http://www.db-staff.com
Go to Top of Page

craig79
Starting Member

33 Posts

Posted - 2009-03-04 : 23:51:54
Yes you are right.
But i need to get these database size from several servers.
For SQL 2005 servers it is fine since i am getting data from one table itself. sys.master_files
But i do have some SQL 2000 servers from where i have to get their DB size too.But in this case i have to query the individual sysfiles table for each database.So is a cursor within cursor acceptable here ?
Also i am running a procedure from one server to capture data of several other servers at once.This includes SQL 2000 as well SQL 2005 servers.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-03-05 : 02:00:47
See if you can make use the result generated by this

select name+'...sp_databases' from sys.servers
where product='SQL Server'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -