Faiz
Faiz

Reputation: 5453

In SQL Server how to give only "read only" permission to all DB objects?

I need to give read only permission to a couple of users on the database so that they can get an understanding of the schema, logic in SPs, etc. But I do not want them to modify anything. I tried assigning the db_datareader role but it doesn't allow viewing SP name or code. What is the right role-combination to do this or do I need to write a T-SQL script to achieve this?

Upvotes: 2

Views: 11304

Answers (2)

Lloyd McFarlin
Lloyd McFarlin

Reputation: 378

Assuming you want to grant the rights to view everything under the dbo schema:

GRANT VIEW DEFINITION ON schema::dbo TO [UserName]

Upvotes: 4

Jeff S
Jeff S

Reputation: 7484

I believe you will have to write a TSQL script to grant view on the SP's. DB_DataReader only gives read access to the user tables; it doesn't include any other rights. And I know of no included database role or server role that will do what you are asking.

Upvotes: 0

Related Questions