Sunday, March 25, 2012
Check NT login existance
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?
Check NT login existance
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?
Check NT login existance
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?sql
Thursday, March 22, 2012
Check If View Exists
An easy way to do this is to use the INFORMATION SCHEMA objects. They provide a handy way to get at the tables/views/etc inside the database..
Code Snippet
USE MyDatabase;
SELECT * FROM INFORMATION_SCHEMA.VIEWS
If you need to look for anything else inside the database, there are a bunch of others:
http://msdn2.microsoft.com/en-us/library/ms186778.aspx
|||I really appreciate that. Thank you.Check If View Exists
An easy way to do this is to use the INFORMATION SCHEMA objects. They provide a handy way to get at the tables/views/etc inside the database..
Code Snippet
USE MyDatabase;
SELECT * FROM INFORMATION_SCHEMA.VIEWS
If you need to look for anything else inside the database, there are a bunch of others:
http://msdn2.microsoft.com/en-us/library/ms186778.aspx
|||I really appreciate that. Thank you.Check If View Exists
An easy way to do this is to use the INFORMATION SCHEMA objects. They provide a handy way to get at the tables/views/etc inside the database..
Code Snippet
USE MyDatabase;
SELECT * FROM INFORMATION_SCHEMA.VIEWS
If you need to look for anything else inside the database, there are a bunch of others:
http://msdn2.microsoft.com/en-us/library/ms186778.aspx
|||I really appreciate that. Thank you.