Solved

T SQL for usermapping assignment to a user SQL Server 2005

Posted on 2009-05-06
2
231 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sql query 12 72
Query to Add Late Tolerance 10 67
kill process lock Sql server 9 49
SQL query with cast 38 42
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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