Passing a pre-set parameter to a Stored Proc

  • How can I pass a pre-set parameter to a stored proc, for example;

    DECLARE @param1 VARCHAR(MAX)

    SET @param1 = 'value1, value2, value3'

    EXEC usp_doStuff @command1 = 'Some stuff goes here', @command2 = @param1;

    When I try this I get "Must pass parameter number 2 and subsequent parameters as '@name = value'."

    I probably (hopefully) missing something easy here, any help appreciated. Thanks!

  • ReamerXXVI (1/29/2013)


    How can I pass a pre-set parameter to a stored proc, for example;

    DECLARE @param1 VARCHAR(MAX)

    SET @param1 = 'value1, value2, value3'

    EXEC usp_doStuff @command1 = 'Some stuff goes here', @command2 = @param1;

    When I try this I get "Must pass parameter number 2 and subsequent parameters as '@name = value'."

    I probably (hopefully) missing something easy here, any help appreciated. Thanks!

    Um, you should be fine there, unless there's further parameters in the proc itself that don't have defaults.

    Can you show us the header of the proc usp_doStuff? Everything between the CREATE and the AS, at the least.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Hi, thanks for your reply, you are absolutely right, it does work.

    I was making a mistake elsewhere, all resolved now.

    Thanks again.

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

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