Create PROCEDURE wls_GetRateByDate
@Date DateTime,
@Rate decimal(10,4) output
as
Begin
if exists(select MileageRate from MileageInfo where @Date between EffectiveDate and ExpirationDate)
  select @Rate = MileageRate from MileageInfo where @Date between EffectiveDate and ExpirationDate 
else
 select @Rate = MileageRate from MileageRateHistory where @Date between EffectiveDate and ExpirationDate
end
GO
declare @Rate decimal(10,4)
execute wls_GetRateByDate '2005-5-19',@Rate output --加上output
select @Rate