Hi Folks.
I'm sure one of you out there must have come across this problem.
I'd like to put the names of all active databases in a cursor so I can loop through them. They have to be up and running though - not in single-user mode for example - as the query I'm using falls over when trying to access this information. Surely there must be a table somewhere that holds this?
There's sp_helpdb which looks like it might return available databases only. This is a pain though as it's a stored proc and I'll need a temp table or something to specifically get at the db names. I could do this but need a well opimised query.
There's also master.dbo.sysdatabases. It contains db names but no reliable field to restrict results to avialable db's only. The status field is unreliable, for example, autoshrink is reflected in the status instead of single-user mode if both criteria apply.
If anyone has a nice quick efficient query to extract available database names I'd be delighted to hear from them.
Thanks
Bob
I'm sure one of you out there must have come across this problem.
I'd like to put the names of all active databases in a cursor so I can loop through them. They have to be up and running though - not in single-user mode for example - as the query I'm using falls over when trying to access this information. Surely there must be a table somewhere that holds this?
There's sp_helpdb which looks like it might return available databases only. This is a pain though as it's a stored proc and I'll need a temp table or something to specifically get at the db names. I could do this but need a well opimised query.
There's also master.dbo.sysdatabases. It contains db names but no reliable field to restrict results to avialable db's only. The status field is unreliable, for example, autoshrink is reflected in the status instead of single-user mode if both criteria apply.
If anyone has a nice quick efficient query to extract available database names I'd be delighted to hear from them.
Thanks
Bob