Solved

T SQL for usermapping assignment to a user SQL Server 2005

Posted on 2009-05-06
2
209 Views
Last Modified: 2012-05-06
I want to give db_owner to a user , username1 for database dbname1

1. security => logins
2. Right click username1
3. click properties
4. click usermapping
5. choose database dbname1
6. check the db_ower  at the lower pane

When I close the screen and go back in, the "db_owner" is unchecked

I like to know if I can use a T SQL statement to assign this permission , "db_owner" for user "username1" to database "dbname1"

Thanks
0
Comment
Question by:Greens8301
2 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 24318020
make sure the users exists in the db
create user username for login username


then grant it to the role
EXEC sp_addrolemember 'db_owner', 'username'
0
 

Author Comment

by:Greens8301
ID: 24318178
Thanks very much. It worked.
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.

Join & Write a Comment

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

757 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

21 Experts available now in Live!

Get 1:1 Help Now