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
 Transact-SQL (2005)
 script

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2010-12-22 : 13:01:58
I need a script to create a windows authenication login in sqlserver 2005.If the login doesn't exists.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2010-12-22 : 14:48:50
[code]if not exists (select * from sys.server_principals where name = 'DomainName\loginname')
create login [DomainName\loginname] from windows;
[/code]There are a few options you can specify if you need to. Documentation and examples here: http://msdn.microsoft.com/en-us/library/ms189751.aspx
Go to Top of Page
   

- Advertisement -