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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL 12 vs sp_dboption 1

Status
Not open for further replies.

denimined

Programmer
Sep 29, 2004
54
CA
I am looking for a replacement for sp_dboption for determining if a database is READONLY.
Previously, sp_dboption '<database>', 'read only' would return an ON / OFF status.

All the material that I have found so far talks about using ALTER DATABASE to actually change settings. I don't want to change the database setting - I just want to find out what that setting currently is.

Any assistance is greatly appreciated!
[peace]
 
Code:
SELECT DATABASEPROPERTY('YourDBName','IsReadOnly')


Borislav Borissov
VFP9 SP2, SQL Server
 
Great! Thank you.

Now, since this only works for an SQL 12 server, does anyone have a (relatively) simple way to find out what version of server you are on - that will work with older and newer servers?

i.e.
server < 12 = use sp_dboption
server >= 12 = use databaseproperty

Thx again.


 
Doh!!! Never mind...
@@VERSION gets me what I need.

lololol
 
The databaseproperty function was introduced in SQL 2005. This may give you a slightly easier way fo finding the version:
Code:
select serverproperty('productversion')
 
Actually, serverproperty is what I ended up using in my application code, but thank you for the post.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top