NEED SQL to place DB in ReadOnly from Query Analyzer

  • Rather than use the SQL Server 200 Enterprise Manager GUI:

    -- I am looking for SQL which will place multiple DB's on a single SQL Server (2000) in Read Only status.  (single user mode is not required but if you have that parameter, it will be useful at a later date)

    -- Can I execute the SQL from the MASTER DB Query Analyzer session?

    BT
  • what about

    alter database yourdatabase set read_only

    ?

  • You can't set the options on multiple databases in one statement.  But you can set multiple options on one database in one statement.

    ALTER DATABASE <db> SET READ_ONLY, SINGLE_USER

      [ WITH { ROLLBACK IMMEDIATE | NO_WAIT | ROLLBACK AFTER nn SECONDS } ]

    Both READ_ONLY and SINGLE_USER settings will be blocked if other users are in the database, the termination clause specifies what to do about them.

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

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