I have the following query that generates the next available bill of lading numbers.
ALTER PROCEDURE [dbo].[GetNextTruckBol]
@FacilityId INT,
@Count INT = 1
AS
BEGIN
SET NOCOUNT ON;
UPDATE Facilities
SET NextTruckBol = NextTruckBol + @Count
OUTPUT DELETED.NextTruckBol
WHERE Id = @FacilityId
END
But now I need to modify it so that the resulting value is instead assigned to an OUTPUT parameter.
I know how to declare the OUTPUT parameter. How can I assign the value of OUTPUT DELETED.NextTruckBol to that parameter?
Per the
UPDATEdocumentationSo if you know that the
UPDATEwill only affect max one row (asIdis constrained to be unique) and you don't want to mess around with table variables you can useSo that would be