Call stored Proc from a stored Proc

  • Hi

    I am planning to call a stored Proc from another stored Proc...

    what will be the right syntax..will the following work..

    ----------------------------------

    CREATE PROCEDURE [dbo].[SPUpdateDelLookup]

     ( @OldTypeCode  [varchar](3),

       @NewTypeCode  [varchar](3),

       @NewTypeDesc  [varchar](128))

    AS

    IF EXISTS(SELECT TypeCode FROM Lookup WHERE  TypeCode = @OldTypeCode)

     BEGIN

       EXEC dbo.SPDeleteLookup @OldTypeCode

       EXEC dbo.SPInsertLookup @NewTypeCode,@NewTypeDesc

     END

    GO

    ----------------------------------

  • Without knowing the details, it looks as though it will work.

    I would be inclined just to have an UPDATE statement rather than call the DELETE and INSERT SPs.

    If you want a DELETE followed by an INSERT, at least put them in a TRANSACTION.

     

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

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