Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

sql server user restrict to one schema

Posted on 2008-10-02
4
Medium Priority
?
701 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
  • 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 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

963 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