0

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 for 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"?

4

2 回答 2

4

如果 SP 中的参数有默认值,则不必传入。

于 2011-07-14T09:01:33.463 回答
3
  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
于 2011-07-14T09:09:02.757 回答