SQL Job only 1 step

  • Hi, Inside the step I am granting permissions, creating users etc.

    If a user already exist or already has the permissions, I would like the script to continue. Instead, as soon as it sees that user USER1 exist, the job failed.

    Thank you for your help.

    CREATE USER [USER1] FOR LOGIN [USER1]

    CREATE USER [USER2] FOR LOGIN [USER2]

  • Try adding the following statement before CREATE USER:

    IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'USER1')

  • Thanks for the reply. I will try that. In my script I also grant permissions and do other stuff. Isn't there a "catch all" error I can add to my script to force the step to continue even if it encounters an error. Thanks again for helping me.

  • A "Catch All"? Not that I'm aware of.

    SQL Server 2005 now has BEGIN TRY and CATCH blocks that can be used, but I'm not sure if they work within SSIS tasks. They definately work with stored procedures which can be called from SSIS tasks.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply