Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding users and rules.

Status
Not open for further replies.

Proqrammer

Programmer
Sep 17, 2006
64
Hi there,

I have created a user in the server with "exec sp_addlogin" and I can see the user being created in security section of the server.

I also want the user to be given some rules such as db_owner or db_datareader so that it can use the database, how can I assign a created user to a database and give some rules to it?

I'm looking for stored procedures, and I'm using Ms SQL 2005


Thanks
 
you're looking for sp_addrolemember

____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done
 
After you add the user to the server using either CREATE LOGIN or sp_addlogin you need to add the user to the database using either the CREATE USER to sp_adduser procedure.

It is recommend in SQL 2005 to use the CREATE USER and CREATE LOGIN commands as the procedures are being phased out after SQL 2005.

After you have added to the user to the database you can add the user to the role via the sp_addrolemember that onpnt gave you above.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top