Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to return MS SQL server Database Status as shown in the Image attached, in C# like it should return me "Offline" , "pending" or other.

[Click For Image]
Posted
Updated 8-Aug-14 1:04am
v2
Comments
Herman<T>.Instance 8-Aug-14 6:13am    
I do not open images from links.....
SRK90 8-Aug-14 6:19am    
you mean, if the database value says offline or pending or etc.....an image should get displayed on your web page based on the different status instead of printing offline, pending or etc???? .....Please correct me if i am wrong.
ali_khan_1 8-Aug-14 7:06am    
no not the values...in front of DB name in braces there is a status how to return that with DB name

select name,state_desc from sys.databases
 
Share this answer
 
Comments
[no name] 8-Aug-14 7:20am    
+5You can see my solution also (Solution 2)
SELECT DB_NAME() AS DatabaseName, DATABASEPROPERTYEX('master', 'Status') AS DBStatus
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900