locked
Passing different number of parameters to a Stored Procedure RRS feed

  • Question

  • Hi to all,

    How can I Pass different number of parameters to a Stored Procedure?

    In my Requirement,

    Some times i want to pass 2 parameters only,

    In some cases i want to pass 6 parameters.

    How can i do this?

    Please give me a solution.

    Thanx in advance...

    Monday, January 22, 2007 9:55 AM

Answers

  • You will have to use optional parameters then. The procedure head should look like something as the following:

    CREATE PROCEDURE SomeProc
    (
      SomeParam INT = NULL,
     SomeOtherParameter INT = 2
    )(...)

    HTH, jens K. Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---

    Monday, January 22, 2007 1:25 PM