How to find out database status is in read only or not?

  • What is the best way to find out whether database is readonly state or read write state? My requirement is to from a central sql box connect to all linked servers and get a list of databases that are in read only state.

    Is there anyway to know this without using sp_dboption on each database? Like  from the master database ?  Sysdatabases table status column have the bit value combined for the settings. Is there any other possibility to acheive this.

     

    Thanks...

     

     

     

     

  • This should do it.

    select
     ReadOnly = databaseproperty(a.name ,'IsReadOnly'),
     a.name
    from
     master.dbo.sysdatabases a
    order by
     a.name
     

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply