# MS SQL client providing read-only mode

I have a MS SQL database with some very, very sensitive data. If anything gets broken, half of the planet will fall into chaos. Almost :-).

I have a database user with some restricted permissions, but not restricted enough, I could do some damage if I made a mistake. Basicaly I just need to do a SELECT from some tables with some fancy sorting, filtering, joining etc. So I would like to use some client software (I am used to HeidiSQL). However I am really afraid of some stupid click on a wrong button and damaging the data.

Is there any way to restrict my own permissions for just one database session? Or is there any safe tool, which provides read-only mode? HeidiSQL does not, unfortunately.

## 1 Answer

I think the only safe way to do this is on the DBMS side. Like you said, some user might do something wrong by accident, or worse, could do something wrong on purpose. In SQL Server you can add the user to the db_datareader role which only allows the user to do SELECT:

Members of the db_datareader fixed database role can run a SELECT statement against any table or view in the database.

You can create a new user with that role by running the following command on the database server:

exec sp_addrolemember 'db_datareader',YourLogin


See:

With this restricted user you can let other users explore the data with any client, such as HeidiSQL, without them being able to change anything in the database.

• Thank you for your answer! However, this is not what I was really looking for... Thank you, anyway. – vojta Nov 7 '15 at 13:07