Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Adding Users to DB

Author  Topic 

Grifter
Constraint Violating Yak Guru

274 Posts

Posted - 2010-09-17 : 05:28:58
Hi

I have a statement where I add users to the DB as follows:

INSERT INTO USERS
(UserName, FullName)
VALUES
('username', 'Full Name')

INSERT INTO UsersGroups
(UserName, [Group])
VALUES
('username', 'group1')
GO


And I then have to go into the DB under logins, create the new login and add the password through sql server authentication, then assign them to the particular DB. Is there a way I can do this all in one, especially as I am going to be adding a lot of users and do not want to have to keep going in and manually typing in the details for each user?

Thanks

G

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-17 : 11:52:27
have a look at CREATE USER statement

http://msdn.microsoft.com/en-us/library/ms173463(v=SQL.90).aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -