?
Solved

Create  a ReadOnly User  - in sql code

Posted on 2015-02-18
1
Medium Priority
?
58 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
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, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

770 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