Solved

sql server user restrict to one schema

Posted on 2008-10-02
4
688 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 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

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