Is there any way to check whether the login exists before creating login ?
create login should be executed after check.
thanks,
Sreenath
Try something like this:DECLARE @.SqlStatement nvarchar(4000)
Declare @.loginName varchar (100)
Select @.loginName = 'test\thermanson'
If not Exists (select loginname from master.dbo.syslogins where name = @.loginName and dbname = 'PUBS')
Begin
Set @.SqlStatement = 'CREATE LOGIN [' + @.loginName + '] FROM WINDOWS WITH DEFAULT_DATABASE=[PUBS], DEFAULT_LANGUAGE=[us_english]'
End
No comments:
Post a Comment