Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Status 1

Status
Not open for further replies.

DBAWinnipeg

Programmer
Apr 14, 2004
173
CA
Does anyone have a script that will return all "online" databases on a server?

What I mean by online is available for Read/writes, etc... not in read only mode, or single user, or dba only, etc

Just something that will return all available dbs.



Thanks in advance!!!

Colin in da 'Peg :)
 
Try this:

Code:
SELECT name,
	DATABASEPROPERTYEX(name, 'status') AS status,
	DATABASEPROPERTYEX(name, 'useraccess') AS user_access,
	DATABASEPROPERTYEX(name, 'isinstandby') AS standby
FROM master..sysdatabases
WHERE DATABASEPROPERTYEX(name, 'status') = 'online'
	AND DATABASEPROPERTYEX(name, 'useraccess') = 'multi_user'
	AND DATABASEPROPERTYEX(name, 'isinstandby') = 0
ORDER BY name

--James
 
Something like ...

Code:
select * from Master..sysdatabases

Thanks

J. Kusch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top