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
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 script

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2010-12-22 : 13:29:09
I need a script to check for the users not exists and then create a windows authenication logins in sqlserver 2005.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-12-22 : 13:45:22
How would you check if a user doesn't exist?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2010-12-22 : 14:40:21
Sorry if i am not clear..
I want to check a if the user already assigned the database.
If the already assigned then ignore else create the new users.


IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE name =
N'AM\sam')

BEGIN
CREATE LOGIN AM\sam FROM WINDOWS WITH DEFAULT_SCHEMA = Marketing;
END

Can you correct the above code.
Go to Top of Page
   

- Advertisement -