Store Procedure

  • Hi,

    How can i write the store procedure which takes input parameter?

    SELECT RM.RName, RM.Logo, MST.PUrl, RM.HPUrl

    FROM MST INNER JOIN

    RM ON MST.DId = RM.DId AND MST.STid = RM.STid

    WHERE (MST.DId = 32) AND (MST.PID = '1G16') AND (RM.Flag = 'True')

    ORDER BY RM.Rank

    I need to pass MST.DId = 32 AND MST.PID = '1G16' both as an Input variables

    Thanks for oyur help!

  • yes, you should look in Books OnLine

    For better, quicker answers, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Pretty basic stuff. Here's a basic answer...

    CREATE PROCEDURE MyProc

    (@DId int,

    @PID varchar(20) )

    AS

    SELECT RM.RName, RM.Logo, MST.PUrl, RM.HPUrl

    FROM MST INNER JOIN

    RM ON MST.DId = RM.DId AND MST.STid = RM.STid

    WHERE (MST.DId = @DId) AND (MST.PID = @PID) AND (RM.Flag = 'True')

    ORDER BY RM.Rank

    Then EXEC as

    EXEC MyProc 16, '1G16'

    Rob Schripsema
    Propack, Inc.

  • Thank you very much!

    I got it the same way but really appreciate your help!

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

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