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.
Author |
Topic |
vaddi
Posting Yak Master
145 Posts |
Posted - 2006-08-22 : 11:12:28
|
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
191 Posts |
Posted - 2006-08-22 : 11:26:49
|
You can do like this:SELECT DatabasePropertyEx('Your_DB_Name','Status')ThanksSanjeev Shrestha12/17/1971 |
|
|
vaddi
Posting Yak Master
145 Posts |
Posted - 2006-08-22 : 12:53:46
|
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 offlineThanks |
|
|
sanjnep
Posting Yak Master
191 Posts |
Posted - 2006-08-22 : 13:14:30
|
You can do some thing like this: GOUSE MASTERDECLARE @dbname VARCHAR(100)DECLARE dbname_cursor CURSOR FORSELECT nameFROM sysdatabasesOPEN dbname_cursorFETCH NEXT FROM dbname_cursorINTO @dbnameWHILE @@FETCH_STATUS = 0 BEGIN SELECT @dbname AS DBName, Databasepropertyex(@dbname,'Status') AS Status FETCH NEXT FROM dbname_cursor INTO @dbname ENDCLOSE dbname_cursorDEALLOCATE dbname_cursorSanjeev Shrestha12/17/1971 |
|
|
|
|
|