Is there any way to disregard a SQL stored procedure's output parameters?
I have a stored procedure that performs some processing and returns a bunch of output parameters. I want to call the stored procedure just for the processing, and don't really care about the output parameters. Is there any way to call the stored procedure without having to declare variables fo开发者_如何学Pythonr all the output parameters?
In case this isn't clear... I don't want my stored procedure call to have to look like this:
DECLARE @param1, @param2, @param3 float
DECLARE @param4, @param5 datetime
DECLARE @param6, @param7, @param8, @param9 int
etc.,etc.
EXEC MyStoredProcedure @param1 OUTPUT, @param2 OUTPUT, @param3 OUTPUT, @param4 OUTPUT.......
I want to be able to just say:
EXEC MyStoredProcedure
Is there any way to specify "I don't care about output parameters - ignore them"?
If the parameters in the SP have default values, they do not have to be passed in.
CREATE PROCEDURE test (@id INT = 0 OUTPUT)
AS
BEGIN
SELECT @id = @id + 1
SELECT @id
END
GO;
DECLARE @x INT
SET @x = 9
EXEC test @x OUTPUT
SELECT @x
EXEC test @x
SELECT @x
EXEC test
精彩评论