Any idea why the following would not work as a stored procedure? RequisitionIDin is an input parameter that is an integer. I get an error on the ORDER BY that says that First cannot be used in this context.
SELECT FIRST 1 po.PONbr, pr.RequisitionID
INTO WorkLastPONbr, WorkRequisitionID
FROM PurchaseRequisition pr INNER JOIN PurchaseOrder po
ON pr.RequisitionID = po.RequisitionID
WHERE pr.ItemID = (SELECT ItemID
WHERE RequisitionID = RequisitionIDin)
AND pr.RequisitionID < RequisitionIDin
ORDER BY pr.RequisitionID Desc;
This runs as a regular statement, but it will not work when trying to create a stored procedure with it.