I have a table that stores the start date and end date of appointment in two different columns. They are both date times. Its for easy importation of the old data. I cant change the structure. I am using Microsoft SQL Server.
ApptDate ApptTime
2012-02-16 00:00:00.000 1899-12-30 11:45:00.000
2012-02-16 00:00:00.000 1899-12-30 13:15:00.000
2012-02-16 00:00:00.000 1899-12-30 13:30:00.000
What I need to do is combine these two date times in one. I am calling a stored proc. My question is what would be my best way of doing this?
ALTER PROCEDURE [dbo].[GetTodaysAppointsNonRepeating]
-- Add the parameters for the stored procedure here
@DateToday DATETIME, @ClientID INT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT a.ID, a.ApptDate, a.ApptTime, a.ApptLength, a.checkedin, a.Entered, a.UserID, a.ProviderID, a.PatientID, CASE WHEN patient.FirstName is null then a.Name END as name,
CASE WHEN HomePhone !='' then HomePhone WHEN WorkPhone !='' THEN WorkPhone ELSE CellPhone END as Telephone
FROM Appointments as a INNER JOIN Patient on a.PatientID = patient.id and
a.clientid = patient.clientid WHERE ApptDate = @DateToday and a.ClientID = @ClientID
AND RepeatType = 'N'
END