ALTER PROCEDURE [dbo].[usp_vehicleabsence_enumerate]
@onDay DateTime
AS
BEGIN
-- If we have not been passed a specific date then include all absence records
IF @onDay IS NOT NULL
SELECT ivehicleabsence.* ,ivehicle.*
FROM ivehicleabsence
LEFT JOIN ivehicle ON (ivehicleabsence.ivehicle_id = ivehicle.ivehicle_id)
WHERE ivehicleabsence.ivehicleabsence_start <= @onDay
AND ivehicleabsence.ivehicleabsence_end >= @onDay
ELSE
SELECT ivehicleabsence.* ,ivehicle.*
FROM ivehicleabsence
LEFT JOIN ivehicle ON (ivehicleabsence.ivehicle_id = ivehicle.ivehicle_id)
END
|