Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2015
    Posts
    38
    Provided Answers: 1

    Unanswered: Only run Stored procedure if update records exist

    I am trying to put together a Stored Procedure that runs other SP's based on a records found condition. Sometimes my update table either by deleting duplicates or for other reasons is empty. Running a SP to update records on a table is not needed. I am thinking something like this would work.

    IF EXISTS (SELECT TOP 1 * FROM Work_Tables.dbo.Trace_Return_Updates WHERE TR_RecType = 'CT1')
    BEGIN
    EXEC IMB_Trace_Data.dbo.Update_CT1_Trace_Data
    END

    IF EXISTS (SELECT TOP 1 * FROM Work_Tables.dbo.Trace_Return_Updates WHERE TR_RecType = 'CT2')
    BEGIN
    EXEC IMB_Trace_Data.dbo.Update_CT2_Trace_Data
    END

    IF EXISTS (SELECT TOP 1 * FROM Work_Tables.dbo.Trace_Return_Updates WHERE TR_RecType = 'FULF')
    BEGIN
    EXEC IMB_Trace_Data.dbo.Update_FULF_Trace_Data
    END
    Last edited by wjburke2; 10-06-15 at 17:33.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What do the nested procedures look like?

    Chances are, the additional EXISTS checks are unnecessary.
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •