October 8, 2007 at 11:55 pm
Hi there,
i have a stored procedure and many parameters. i want to use "exec sp_name" and give some parameters of them then how can i give values for specific parameters.
Please Help. 🙂
October 9, 2007 at 2:03 am
g.sarvesh (10/8/2007)
Hi there,i have a stored procedure and many parameters. i want to use "exec sp_name" and give some parameters of them then how can i give values for specific parameters.
Please Help. 🙂
Could you tell us more about the problem you are trying to solve. Where are you trying to call your stored procedure from? Are you executing it many times with different parameters? ...
If you have a proc like:
CREATE PROC proce2 ( @a INT, @b-2 INT = 3, @C INT )
AS
SELECT @a + @b-2 + @C AS result
GO
(three parameters, one has a default value, then you can execute it like:)
-- declare variables
DECLARE @param1 INT
DECLARE @param2 INT, @param3 INT
-- set variable values
SELECT @param1=1, @param2=2, @param3=3 -- here you can set the value of several variables
-- OR:
SET @param1=1
-- execute the proc
EXEC proce2 @param1, @param2, @param3
EXEC proce2 @a=@param1, @C=@param3, @b-2=@param2 -- if you name the parameters you can play with their order
EXEC proce2 @C=@param3, @a=@param1 -- uses the default for the second parameter
Regards,
Andras
October 10, 2007 at 5:35 am
Thanx for giving answer but i have done it.
mention not, next time meet u.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply