select [Message].Phone,
[Message].ScheduledDate as Date,
[Message].SentDate,
[Message].DeliveryTime,
[Message].Text,
[Message].Status
from [Message]
inner join [Schedule] on [Message].Phone = [Schedule].Phone
where (ScheduledDate BETWEEN @start AND @end)
and ([Message].Phone = @phone or @phone is null)
order by [Message].ScheduledDate asc