Stored Procedure

  • Dear All,

    This is a doubt regarding the stored procedures...How do I call a stored procedure inside another stored procedure? If anyone has an idea on this plz do take part...plz reply with ur valuable comments....

     

    Thanks

    A Sunil

     

  •  

    Try this..

    USE Northwind

    GO

    CREATE PROCEDURE Proc2 @CustomerID nchar(5)

    AS

    BEGIN

     DECLARE @OrderID int

     EXEC Proc1 @CustomerID, @OrderID OUTPUT

     SELECT Od.OrderID,

      ProductName,

      UnitPrice=ROUND(Od.UnitPrice, 2),

      Quantity,

      Discount=CONVERT(int, Discount * 100),

      ExtendedPrice=ROUND(CONVERT(money, Quantity * (1 - Discount) * Od.UnitPrice), 2)

     FROM  Products P, [Order Details] Od

     WHERE  Od.ProductID = P.ProductID and Od.OrderID = @OrderID

    END

    GO

    CREATE PROCEDURE Proc1

    ( @CustomerID nchar(5), @OrderID int OUTPUT )

    AS

    SELECT  TOP 1 @OrderID = OrderID

    FROM  Orders

    WHERE  CustomerID = @CustomerID

    ORDER  BY ShippedDate

    GO

    Proc2 'VINET'

    GO

  • Thanks Srikanth

    I tried it and it is working...

    Regards

    A sunil

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

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