Pass parameters to stored procedures in SQLServer 2008

Asked By 10 points N/A Posted on -
qa-featured

How do I pass formatted parameters to stored procedures in SQLServer 2008 ?

SHARE
Answered By 0 points N/A #94666

Pass parameters to stored procedures in SQLServer 2008

qa-featured

Hi,

Parameter values can be supplied if a stored procedure is written to accept them.

The supplied value must be a constant or a variable; you cannot specify a function name as a parameter value. Variables can be user-defined or system variables such as @@spid.

The following examples demonstrate passing parameter values to the stored procedure uspGetWhereUsedProductID. The procedure expects values for two input parameters: a product ID and a date. The examples show how to pass parameters as constants and variables and also how to use a variable to pass the value of a function.

If you supply parameters in the form @parameter = value, you can supply them in any order. You can also omit parameters for which defaults have been supplied. If you supply one parameter in the form @parameter = value, you must supply all subsequent parameters this way. If you do not supply parameters in the form @parameter = value, you must supply them in the order given in the CREATE PROCEDURE statement.

When executing a stored procedure, the server rejects any parameters that were not included with the parameter list during procedure creation. Any parameter passed by reference (explicitly passing the parameter name) is not accepted if the parameter name does not match.

Thanks

Related Questions