Link to home
Start Free TrialLog in
Avatar of yanci1179
yanci1179

asked on

sql server user restrict to one schema

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?
Avatar of chapmandew
chapmandew
Flag of United States of America image

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
sorry last one should be:

grant select on schema::accounting to username
ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
grant has a schema option here's the details.

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