How to set a SQL Server database in read only or read write mode

In this tutorial we will see how we can place our SQL Server database in ReadWrite mode:

  • Set database to read only
  • ALTER DATABASE DB_NAME SET READ_ONLY
  • Check database is read only
  • EXEC sp_dboption 'DB_NAME', 'read only'
  • Set database read write
  • ALTER DATABASE DB_NAME SET READ_WRITE
  • Check database status
  • EXEC sp_dboption 'DB_NAME', 'read only'