I have a stored procedure that accepts 10 parameters. I want to send some of these parameters when executing another stored procedure. How can I do that?
Stored procedure definition:
create PROCEDURE [dbo].[SP_name]
@p1 int = null,
@p2 int = null
..
..
@p10 int = null
Execute statement :
exec SP_name valueForP2,vlaueForP5..;
Are there any why to tell exec statement to take just some of the variables?
You can specify the parameter names in the call to the procedure, the other parameters will use the default values.
create PROCEDURE [dbo].[SP_name]
@p1 int = null,
@p2 int = NULL,
@p10 int = NULL
AS
SELECT @p1, @p2, @p10
GO
-- Execute using named parameters
EXEC [SP_name] @p1 = 1, @p10 = 5;