Sunday, March 25, 2012

Check NT login existance

How do you check for the existance of an NT login (in the domain not on sql
server itself) in a script that uses sp_grantlogin?
You can use SUSER_SID:
IF SUSER_SID('MyDomain\MyAccount') IS NULL
PRINT 'account does not exist'
ELSE
PRINT 'account exists'
Happy Holidays
Dan Guzman
SQL Server MVP
"Steve Morris" <SteveMorris@.discussions.microsoft.com> wrote in message
news:FB40D121-995B-42DE-B735-7597C4793404@.microsoft.com...
> How do you check for the existance of an NT login (in the domain not on
> sql
> server itself) in a script that uses sp_grantlogin?

No comments:

Post a Comment