Link to home
Start Free TrialLog in
Avatar of dec789
dec789

asked on

How to add a new user to a Data base with out going through the "New User" window?

Is there a way to add a user to a SQL server data base without going through the Enterprise Manager's New User window?  Can I some how do this in "code" or a "stored procedure"?  I'm very new with SQL Server as you can probably tell from my question.
ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hmmm...just noticed that you posted zone 2005, but 2000 as a tag...which one is it?

Also, for best practices, you should use the create user statement if it is 2005, but sp_adduser will work with both.
Avatar of dec789
dec789

ASKER

I'm sorry chapmandew, Where exactly do I enter this code?  In the Query Analyzer?
Avatar of dec789

ASKER

I'm using SQL Server 2000 but there was no option for that when I submitted the question.  
in a new query editor window in query analyzer....make sure it is in the database context that you want to create the user...you have to already have a login created to map the user to.  logins are associated w/ logins into the instance, users are associated w/ the database.
Avatar of dec789

ASKER

AngelIII this reference is to SQL Server 2005 Books Online (September 2007).

Do you think it also works with SQL Server 2000?  Which is what I'm using.
Nope, create user is for 2005 only.
no. for sql 2000, you will indeed need the syntax suggested by chapmandev
Avatar of dec789

ASKER

Thank you so much chapmandew.  sorry the version I'm using is so out ot date the we will be moving to SQL Server 2005 shortly.  The company I work for is slow adapt new technologies.