Home > Archive > MS SQL Server > August 2005 > Determine if database is in standby/read-only mode?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Determine if database is in standby/read-only mode?
Wade

2005-08-30, 8:23 pm

Hi all,

Sorry for the frequent posts, but I have one other thing I'd like to figure
out.

Can I write a query to determine if a database is in standby or read-only
mode? I would like to put a check in the restore routine for custom log
shipping so that DIFFs and TRANS are restored when not in standby/read-only.

I tried to trace Enterprise Mangler, and see how it set the Read-only
checkbox for the database properties, and I saw this ...

USE [<DatabaseName>]
SELECT FILEGROUPPROPERTY( f.groupname, N'IsReadOnly' ) FROM
dbo.sysfilegroups f

However, even though Enterprise Mangler shows read-only as checked, this
query keeps returning false (0).

Any thoughts? Am I going about this the wrong way?

Thanks for the help!

Wade


Wade

2005-08-30, 8:23 pm

Nevermind, I found it:

use [master]
select name, DATABASEPROPERTY(nam
e, N'IsReadOnly') from
master.dbo.sysdatabases

Thanks!

"Wade" < wwegner23NOEMAILhotm
ail.com> wrote in message
news:%23ZxMnTZrFHA.1128@TK2MSFTNGP11.phx.gbl...
> Hi all,
>
> Sorry for the frequent posts, but I have one other thing I'd like to
> figure out.
>
> Can I write a query to determine if a database is in standby or read-only
> mode? I would like to put a check in the restore routine for custom log
> shipping so that DIFFs and TRANS are restored when not in
> standby/read-only.
>
> I tried to trace Enterprise Mangler, and see how it set the Read-only
> checkbox for the database properties, and I saw this ...
>
> USE [<DatabaseName>]
> SELECT FILEGROUPPROPERTY( f.groupname, N'IsReadOnly' ) FROM
> dbo.sysfilegroups f
>
> However, even though Enterprise Mangler shows read-only as checked, this
> query keeps returning false (0).
>
> Any thoughts? Am I going about this the wrong way?
>
> Thanks for the help!
>
> Wade
>



Alejandro Mesa

2005-08-30, 8:23 pm

Use function databaseproperty.

Example:

use master
go

select
[name],
databaseproperty([name], 'IsInStandBy') as IsInStandBy,
databaseproperty([name], 'IsInRecovery') as IsInRecovery
from
sysdatabases
go


AMB

"Wade" wrote:

> Hi all,
>
> Sorry for the frequent posts, but I have one other thing I'd like to figure
> out.
>
> Can I write a query to determine if a database is in standby or read-only
> mode? I would like to put a check in the restore routine for custom log
> shipping so that DIFFs and TRANS are restored when not in standby/read-only.
>
> I tried to trace Enterprise Mangler, and see how it set the Read-only
> checkbox for the database properties, and I saw this ...
>
> USE [<DatabaseName>]
> SELECT FILEGROUPPROPERTY( f.groupname, N'IsReadOnly' ) FROM
> dbo.sysfilegroups f
>
> However, even though Enterprise Mangler shows read-only as checked, this
> query keeps returning false (0).
>
> Any thoughts? Am I going about this the wrong way?
>
> Thanks for the help!
>
> Wade
>
>
>

Narayana Vyas Kondreddi

2005-08-30, 8:23 pm

See DATABASEPROPERTY and DATABASEPROPERTYEX functions in SQL Server Books
Online.
--
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @ http://vyaskn.tripod.com/


"Wade" < wwegner23NOEMAILhotm
ail.com> wrote in message
news:%23ZxMnTZrFHA.1128@TK2MSFTNGP11.phx.gbl...
> Hi all,
>
> Sorry for the frequent posts, but I have one other thing I'd like to

figure
> out.
>
> Can I write a query to determine if a database is in standby or read-only
> mode? I would like to put a check in the restore routine for custom log
> shipping so that DIFFs and TRANS are restored when not in

standby/read-only.
>
> I tried to trace Enterprise Mangler, and see how it set the Read-only
> checkbox for the database properties, and I saw this ...
>
> USE [<DatabaseName>]
> SELECT FILEGROUPPROPERTY( f.groupname, N'IsReadOnly' ) FROM
> dbo.sysfilegroups f
>
> However, even though Enterprise Mangler shows read-only as checked, this
> query keeps returning false (0).
>
> Any thoughts? Am I going about this the wrong way?
>
> Thanks for the help!
>
> Wade
>
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com