February 10, 2006 at 8:24 am
in Quary anaylizer, how do i skip parameters when using a stored procedure
I tryed skipping parameters with commos like other languages with no luck.
say I want to supply only the 1st and 3rd parameter, how do I do this?
February 10, 2006 at 8:28 am
Use named parameters
e.g. exec procname @param1 = n, @param3 = x
February 10, 2006 at 8:31 am
You can input parameters two ways, one allows you to skip parameters and one doesn't.
CREATE PROCEDURE usp_myproc
@param1 CHAR(1) = 'a',
@param2 CHAR(1) = 'b',
@param3 CHAR(1) = 'c'
AS
SELECT @param1, @param2, @param3
GO
Normally, you must enter all parameters in the order they appear in the CREATE PROCEDURE statement. However, if you chose to skip one or more, or want to enter them in a different order...you need to identify the parameters. However, if you are going to skip parameters, each parameter that might be skipped must have a default value assigned.
EXEC usp_myproc @param1 = '1', @param3 = '3'
GO
EXEC usp_myproc @param2 = '2', @param1 = '1', @param3 = '3'
-SQLBill
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply