SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Database Status
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

vaddi
Posting Yak Master

145 Posts

Posted - 08/22/2006 :  11:12:28  Show Profile  Reply with Quote
Hello

I would like to know a script , which gives the status of database either online or offline. I need just this parameter. I donot want to use the sp_helpdb.

Thanks

sanjnep
Posting Yak Master

USA
191 Posts

Posted - 08/22/2006 :  11:26:49  Show Profile  Visit sanjnep's Homepage  Reply with Quote
You can do like this:

SELECT DatabasePropertyEx('Your_DB_Name','Status')

Thanks

Sanjeev Shrestha
12/17/1971
Go to Top of Page

vaddi
Posting Yak Master

145 Posts

Posted - 08/22/2006 :  12:53:46  Show Profile  Reply with Quote
Thanks for the syntax.

Is there any script , that I can use on the master db , and shows me which databases are online and which are offline

Thanks
Go to Top of Page

sanjnep
Posting Yak Master

USA
191 Posts

Posted - 08/22/2006 :  13:14:30  Show Profile  Visit sanjnep's Homepage  Reply with Quote
You can do some thing like this:
GO
USE MASTER

DECLARE @dbname VARCHAR(100)

DECLARE dbname_cursor CURSOR FOR
SELECT name
FROM sysdatabases

OPEN dbname_cursor

FETCH NEXT FROM dbname_cursor
INTO @dbname

WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @dbname AS DBName,
Databasepropertyex(@dbname,'Status') AS Status
FETCH NEXT FROM dbname_cursor
INTO @dbname
END

CLOSE dbname_cursor

DEALLOCATE dbname_cursor


Sanjeev Shrestha
12/17/1971
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000