Adding a new user to SQL server 2005, 2008, 2010

Make sure you give the user sufficient permissions to the DB they are being given access to, typically being db_datareader, db_datawriter, db_ddladmin, and public.

 

There is also a SQL statement you can run:

CREATE LOGIN [user] WITH PASSWORD='password', 
       DEFAULT_DATABASE=[your_db], CHECK_POLICY=OFF
GO

CREATE USER [user] FOR LOGIN [user]
EXEC sp_addrolemember N'db_datareader', N'your_db'
EXEC sp_addrolemember N'db_datawriter', N'your_db'
EXEC sp_addrolemember N'db_ddladmin', N'your_db'
EXEC sp_addrolemember N'public', N'your_db'
GO

I have not tested this script, use at your own risk.  In my example, I give the last two roles that seem to be not included in scripts mentioned on other sites.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *