Friday, February 13, 2009

T-SQL - How to set a Database to be READ_ONLY?

When you create a database in SQL sever, you need to define a filegroup for it, then you can set it READ_WRIE or READ_ONLY

For example, if you have backup database that users can use to inspect data, and you don't need any update on it, then it would be an ideal case to set the database as READ_ONLY.

In this way, you can be sure that no updates can occur, so it has the security.

ALTER DATABASE [Your DataBase Name] SET READ_ONLY
GO


To make the database to be able to be updated, you can use the following line:

ALTER DATABASE [Your DataBase Name] SET READ_WRITE
GO

Share/Bookmark

No comments: