views:

133

answers:

2

I need to know how to interrogate my Microsoft SQL Server to know if a given database has been set to read only or not. Is that possible?

+5  A: 

The information is stored in sys.databases.

SELECT name, is_read_only 
FROM sys.databases 
WHERE name = 'MyDBNAme'
GO

--returns 1 in is_read_only when database is set to read-only mode.
p.campbell
Perfect! THANKS!!!
Giuseppe
+3  A: 

Here is a command to display or set this property.

EXEC sp_dboption "AdventureWorks", "read only"

Sample output

OptionName CurrentSetting    
read only OFF
JohnFx