Sunday, December 30, 2018

Sql Server: how to change the state of database


In this article I am going to explain how to change the state (Read only to Read Write and vice versa) of Sql server database.

Description:
While working on window form application, I have face the issue of read only database on data insert.

Solution:
To resolve this issue we have 2 ways. One using Sql server management studio and 2nd one using Sql query.

Method 1: Using Sql server Management studio
Connect to Sql server database. After that right click on the database (which is read only), select properties. Database properties window will be open, select options. After that in options look for state and change the database read only value to false.

Sql Server: how to change the state of database


Method 2: using Sql query

Run the below given query:

ALTER DATABASE aspmantra SET READ_WRITE WITH NO_WAIT


Note: if you want to change the database state to read only, you can change using both method (Sql server management studio and Sql Query).  Using sql server follow the steps given in method 1, you have to made only one change, set Database read only value to True. Using query, run the below given query:

ALTER DATABASE aspmantra SET READ_ONLY WITH NO_WAIT


No comments:

Post a Comment