If you have more than one records that get displayed in the PatientAppointmentComboBox, and you want to display only one of those, which of those records do you want to display?First, make this change to the stored procedure. That will show only one record, although you won't be able to predict which record will show up.Alter Procedure [dbo].[sp_GetPateintAppointment](@Patient_Id as bigint)asSelect TOP (1)PatientAppointment_Id,FName + ' ' + LName PatientName,Patient_Idfrom dbo.PatientAppointmentwhere Patient_Id = @Patient_Idunionselect0,FName + ' ' + LName PatientName,Patient_Idfrom dbo.v_Patient pwhere Patient_Id = @Patient_Id
If that looks like what you are trying to get, now decided which record to show by adding an "ORDER BY" clause. Suppose you had a column named AppointmentDate in the table, and you wanted to show the row which has the latest AppointmentDate. Then, the order by clause would be like shown below:.Alter Procedure [dbo].[sp_GetPateintAppointment](@Patient_Id as bigint)asSelect TOP (1)PatientAppointment_Id,FName + ' ' + LName PatientName,Patient_Idfrom dbo.PatientAppointmentwhere Patient_Id = @Patient_Idunionselect0,FName + ' ' + LName PatientName,Patient_Idfrom dbo.v_Patient pwhere Patient_Id = @Patient_Idorder by AppointmentDate DESC
But, none of what I described above may be what you are looking for. I didn't quite follow what you meant by you want to show only one record. When you have a combobox, isn't that really meant to list many appointments, with only one of those visible in the control, and the others visible when you click on it?