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
Solved

Create  a ReadOnly User  - in sql code

Posted on 2015-02-18
1
52 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 143

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

840 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