CREATE PROCEDURE usp_FindMissingOrders
@First_orders_id int,
@Last_orders_id int
AS
SET NOCOUNT ON
SELECT n.Number Missing_orders_id
FROM Numbers n
LEFT JOIN Orders o ON n.Number = o.orders_id
WHERE n.Number BETWEEN @First_orders_id AND @Last_orders_id
AND o.orders_id IS NULL
|