Solved

Create  a ReadOnly User  - in sql code

Posted on 2015-02-18
1
49 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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

13 Experts available now in Live!

Get 1:1 Help Now