Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Practice InterviewNew Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

MSSQL Interview Questions and Answers

Ques. How to set database to be READ_ONLY in MS SQL Server?
Ans. Databases in SQL Server have two update options:

* READ_WRITE - Data objects are allowed to be queried and modified. This is the default.
* READ_ONLY - Data objects are allowed to be queried, but not allowed to be modified.

You can use the "ALTER DATABASE" to change database update options as shown in the tutorial below:

USE withoutbookDB
GO

INSERT Links (Name) VALUES ('www.withoutbook.com')
GO
(1 rows affected)

ALTER DATABASE withoutbookDB SET READ_ONLY
GO

INSERT Links (Name) VALUES ('www.withoutbook.com')
GO
Msg 3906, Level 16, State 1, Server SQLEXPRESS, Line 1
Failed to update database "withoutbookDB" because
the database is read-only.

SELECT * FROM Links
GO
Name
www.withoutbook.com

ALTER DATABASE withoutbookDB SET READ_WRITE
GO

INSERT Links (Name) VALUES ('www.withoutbook.com')
GO
(1 rows affected)

As you can see from the output, inserting data into a table is not allowed if the database is in READ_ONLY mode.
Is it helpful? Yes No

Most helpful rated by users:

©2020 WithoutBook