Solved

Sql server Perms?

Posted on 2014-12-02
4
379 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
  • 2
4 Comments
 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 100 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 69

Assisted Solution

by:ScottPletcher
ScottPletcher earned 400 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 69

Accepted Solution

by:
ScottPletcher earned 400 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
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 …

911 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now