Is there a way to set multiple output parameters?
For example, in the stored procedure shown here, I wish to get the NUM_OF_ROWS and the TicketNumberz from the same stored procedure.
Since, I am new I don't know how to go about it...
DECLARE @TicketNumberz VARCHAR(15) OUT
DECLARE @NUM_OF_ROWS INT OUT
DECLARE @INIT INT=1 OUT
SET @TicketNumberz = (SELECT TICKETNUMBER
FROM TicketHistory s1
WHERE TICKETTIME IN (SELECT MAX(S2.TICKETTIME)
FROM TicketHistory] S2
WHERE s1.TICKETNUMBER = S2.TICKETNUMBER)
AND CURRENTSTATUS_ANALYST != 'Closed'
AND CURRENTSTATUS_ANALYST = 'Resolved'
AND TICKETTIME < GETDATE() - 5)
-- after getting all the list of ticket numbers, update query follows to update the ticket status to 'Closed'
WHILE (@INIT <= @NUM_OF_ROWS)
BEGIN
INSERT INTO TicketHistory (CURRENTSTATUS_ANALYST, TICKETNUMBER,
PREVIOUSSTATUS_ANALYST, TICKETTIME, FIELD, CREATEDBY)
VALUES ('Closed', @TicketNumberz,
'Resolved', CURRENT_TIMESTAMP, 'Status', 'Auto.User')
END
What this query basically does it, it would fetch all the ''Resolved' tickets which are older than 5 days and had not been 'Closed' automatically. So doing it manually through this stored procedure.
But, I am stuck because of the following error :
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

DECLAREanOUTPUTparameter like that, the parameter is included as part of the parameter list. Also, the error you get has nothing to do withOUTPUTparameters... That error is about your subquery and it is literally telling you the problem: "Subquery returned more than 1 value." You are trying to assign a scalar variable multiple values; that isn't allowed as it's a scalar variable. What are you actually trying to achieve here?UPDATEorINSERTwith a join