Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sql server Perms?

Posted on 2014-12-02
4
Medium Priority
?
386 Views
Last Modified: 2014-12-02
Hello ,

I went to Databases > Login
Right clicked on the logins and saw this dialog box. See image.
I have a user new – he just needs to run queries within the SQL server. But should I do in this dialog box?
General, server roles, user mapping,  securables etc. – what should I do for this new user  - so that he can’t create or change the DBs but just be able to run  only  update , deletion insertion  queries?
Thank you
perms.png
0
Comment
Question by:Rayne
[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
  • 2
4 Comments
 
LVL 66

Assisted Solution

by:Jim Horn
Jim Horn earned 400 total points
ID: 40477086
>he just needs to run queries within the SQL server.
I'd flush out exactly what 'run queries' means:  On a subset of tables, SELECT only vs. insert-update-delete, does he need some reporting assistance, ..

Tread carefully here.
0
 
LVL 70

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 1600 total points
ID: 40477103
>> But should I do in this dialog box? <<

No, never, not once, not ever.  (I hope that was clear enough :-) ).

Always use a script for assigning permissions.


The 100% structured way to do this is to first create your own user-defined role with all the necessary permissions.  Then assign that user -- and any others that need it -- to that role.  The only disadvantage of this role-based approach is that it doesn't cover dynamic SQL.  Granting permissions directly to the user would allow them to use dynamic SQL on the underlying objects as well.

I'll post sample commands for doing this within a few minutes.
0
 
LVL 70

Accepted Solution

by:
Scott Pletcher earned 1600 total points
ID: 40477115
CREATE ROLE data_reader_writer AUTHORIZATION dbo
CREATE USER user123 WITHOUT LOGIN --for testing; I assume you already have a username to assign permissions to

--using a role
EXEC sp_addrolemember 'db_datareader', data_reader_writer
EXEC sp_addrolemember 'db_datawriter', data_reader_writer
EXEC sp_addrolemember 'data_reader_writer', user123
--granting permissions directly without a role
EXEC sp_addrolemember 'db_datareader', user123
EXEC sp_addrolemember 'db_datawriter', user123

--test this user
EXEC AS USER = 'user123'
SELECT * FROM dbo.dbs
REVERT

DROP USER user123
DROP ROLE data_reader_writer
0
 

Author Closing Comment

by:Rayne
ID: 40477431
thank you Sire (s)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
New style of hardware planning for Microsoft Exchange server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

688 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