EXEC SP from SP

  • Help.  I am calling this EXEC from inside a SP. See Below.

    My problem is this.  When I script out my SPs and reload it is giving me an error that it can't find GetPatientHL7Data.  I am sure because the SPs that it is erroring on are loading before GetPatientHL7Data.

    If this is the problem, I prefer not having to rename GetPatientHL7Data to fall before the SPs that need it.

    I have been trying to

    DECLARE @CMD nvarchar(250)

    SET @CMD = 'GetPatientHL7Data ...

    EXEC @CMD

    but I can't figure out the syntax with all the ', '', ''' stuff.

    Everything after the EXEC are parameters that I need to pass to GetPatientHL7Data.

    Can someone help me out with the syntax.

    OR is there a better way of doing this?

    Thanks in advance.

    Phil

    DECLARE @HL7PracticeID bigint

    DECLARE @HL7PatientID bigint

    DECLARE @HL7Update nvarchar(1)

    SELECT @HL7PatientID = appt.patientid FROM appt WHERE appt.apptid = @ApptID

    SELECT @HL7PracticeID = practice.practiceid, @HL7Update = practice.hl7update from practice, patient WHERE patient.patientid = @HL7PatientID AND practice.practiceid = patient.practiceid

    IF @HL7Update = 'Y'

    BEGIN

    EXEC GetPatientHL7Data

    @PracticeID = @HL7PracticeID,

    @PatientID = @HL7PatientID,

    @ProviderID = @ProviderID,

    @ApptID = @ApptID,

    @ProblemID = -1,

    @Notes = '',

    @Description = '',

    @OrderNote = '',

    @Mode = 'INSERT',

    @LocationID = @LocationID,

    @OrderzID = -1,

    @UserProviderID = -1,

    @user-id = @user-id,

    @MessageToID = -1,

    @Urgent = 'N'

    END

  • Are you getting an error saying that the proc can't be created or that no rows will be added to sysdepends?

     

    The easiest way to figure out the correct '',''' thing is, instead of the exec @cmd (which should be exec (@cmd) ) use print @cmd, then you can check that the quotes are in all the correct places, then when you go to exec you will know it's all good.



    Shamless self promotion - read my blog http://sirsql.net

  • Is the internal SP under a different  owner name?

    If yes, add  owner_name.youre internal_SP

     

    LMT

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

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