how do i read this sql code


I think i'm having a brain cramp. but the exec @failing   stored proc   ..output  
followed by if @failing > 0

 is throwing me off here.  Can someone explain how to "read" the code .    
Is the output stATEMENT rEPLACING THE @FAILING WITH THE return code being st in the stored proc if it errors out?

         set @LocalProcedure = 'up_XL_zUpdateStgSiteToSite'
      exec @Failed = JabilDBImport.dbo.up_zUpdateImportJobEvent
         @ImportJobID = @ImportJobID,
         @Event = 'Update Site',
         @StartDTS = @CreateUpdateDTS,
         @AddMessage = 'Started',
         @Status = 'Processing...',
         @EndDTS = null
      exec @Failed = up_XL_zGetDataSourceID @ImportJobID, @DataSourceID OUTPUT
      if @Failed <> 0
          -- ams 7/9/02 c1/a2
          set @ErrorMessage = @LocalProcedure + ' - Error calling up_XL_zGetDataSourceID'
          return 1
Who is Participating?
TempDBAConnect With a Mentor Commented:
This is just to raise your custom error. You can leave without it as well. You will get a system defined error. But this check will help you if you are doing link server (remote server) call. In that case, even if the procedure fails, the execution of the query mayn't be stopped which will hurt the consistency of the data.
Ken ButtersConnect With a Mentor Commented:
The @Failed is being set to the return code of the called function.

if @Failed<> 0 means if @Failed is NOT zero.

A zero return code usually means success... so it is checking for non-zero... meaning failure.

In your original comment you referrred to @Fail > 0 ... which is different... @Fail > 0 would be checking if the return code is Greater than zero... "<>" means not equal to.
TempDBAConnect With a Mentor Commented:
And the output parameter is not replacing the value of @Failed. The value of the output parameter is stored in @DataSourceID.
rschmehlAuthor Commented:
I'm not sure I understand the exec @Failed proc_ABC , why put the @failedin at all when you are exec Proc_abc?
rschmehlAuthor Commented:
Thanks alot
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.