ReturnId WarehouseId SerialNo Details Status ActionDate ----------- ----------- ----------- ------------- ------ ----------------------- 1 20 NULL Details 1 NULL 2009-06-17 09:01:44.240 2 20 NULL Carlsbad NULL 2009-06-17 09:08:10.533I want the add into my sproc the option to pass in a status code, or none:
CREATE PROCEDURE ap_GetReturnsForWarehouse @WarehouseId INT, @Status TINYINT = NULL AS BEGIN SELECT r.*, p.PartNo, p.Description, u.FullName, w.Caption AS Warehouse FROM Returns r JOIN Parts p ON p.PartId = r.PartId JOIN Warehouses w ON w.WarehouseId = r.WarehouseId JOIN Users u ON u.UserId = r.UserId WHERE r.WarehouseId = @WarehouseId AND r.Status = ISNULL(@Status, r.Status) ORDER BY p.PartNo, r.SerialNo DESC ENDI'm calling it like this:
exec ap_GetReturnsForWarehouse @WarehouseId = 20, @Status = NULLI'm getting no data back.