Solved

sql server user restrict to one schema

Posted on 2008-10-02
4
694 Views
Last Modified: 2012-05-05
I have a sql login that i want to restrict to one schema, how can i do that?

for example user1
and
marketing.customers
accounting.customers

I want user1 to only see marketing.customers.  I have many more under the same schema.  I want the user to me able to select from all the tables that exists for this schema.  Is there a script for this?
0
Comment
Question by:yanci1179
[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
  • 3
4 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 22627483
you can grant the user view definition to the schema you want them to be able to see objects

grant view definition on schema::marketing to username

and to select data

grant select on schema::marketing to username

to resetrict to the other schema

deny select on schema::marketing to username
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 22627488
sorry last one should be:

grant select on schema::accounting to username
0
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 22627490
geez....wrong again.  try this:

deny select on schema::accounting to username
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22627492
grant has a schema option here's the details.

http://msdn.microsoft.com/en-us/library/ms187940.aspx
0

Featured Post

Percona Monitoring and Management and Grafana

Proactive monitoring is vital to a highly-available environment. We have a quick start guide on Experts Exchange for Grafana users.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

623 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