Solved

Create  a ReadOnly User  - in sql code

Posted on 2015-02-18
1
50 Views
Last Modified: 2015-02-21
Hi.
What is the syntax for creating a new USER (login?) that only has READONLY access to a single table.
For example how do I create a NEW user named  'BOB'  who ONLY has READONLY access to the Employee table in Northwind?
thx in advance
0
Comment
Question by:JElster
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40616335
login is not the same as user ...
login is on server level, and the creation sql is documented:
https://msdn.microsoft.com/en-us/library/ms189751.aspx

the user is the mapping of the login in a given database (means for each db in the instance, you would need to map the login again)
that syntax is also documented:
https://msdn.microsoft.com/en-us/library/ms173463.aspx

by default, the user can only read the database structure (table names etc), but no data.
to grant the "read only", you just grant the SELECT permission:
https://msdn.microsoft.com/en-us/library/ms187965.aspx
USE Northwind
go
GRANT SELECT ON dbo.Employee TO BOBO

Open in new window

0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Server 2008 R2 - Execution Plan 3 57
Auditing in Azure SQL Database 3 38
Safely Uninstall SQL Server 2008 R2 Express 3 60
Storage Spaces 3 38
Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now