Solved

T SQL for usermapping assignment to a user SQL Server 2005

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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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