I have a Query used in Access which does not work in SQL Server as it stands:
SELECT
mstPatient.PatientID,
mstPatient.PatientID AS PKNO,
IIf(IsNull([mstPatient].[PPrefix]),'',[mstPatient].[PPrefix]+' ')
+ [FirstName] + IIf(IsNull([MiddleName]),'',+' '+[MiddleName])
+ ' ' + [LastName] AS PatientName,
mstPatient.AgeYears,
mstPatient.Gender,
mstPatient.RegistrationDate,
mstPatient.City,
mstPatient.Occupation,
mstPatient.TieupID,
SCDoctorList.Doctor_Name,
SCDoctorList.DDesignation,
mstPatient.MobileNo,
mstPatient.TelNo,
mstPatient.RefBy,
DateDiff('yyyy',mstPatient.BirthDate,Date()) AS Years,
mstPatient.Area,
mstPatient.Caste,
mstPatient.PatientIdPrivate,
mstPatient.ClinicName,
IIf(mstPatient!Add1<>'', mstPatient!Add1+Chr(13),'')
+ IIf(mstPatient!Add2<>'', mstPatient!Add2+Chr(13),'')
+ IIf(mstPatient!Add3<>'', mstPatient!Add3+Chr(13),'')
+ IIf(mstPatient!City<>'', mstPatient!City+Chr(13),'')
+ IIf(mstPatient!PinCode<>'','-'+mstPatient!PinCode+Chr(13),'')
+ IIf(mstPatient!State<>'',mstPatient!State+Chr(13),'')
+ IIf(mstPatient!Country<>'',mstPatient!Country,'') AS Address,
mstPatient.RemarkLang,
mstPatient.RFirstName + ' ' + mstPatient.RMiddleName+' '
+ mstPatient.RLastName AS RPatientName,
mstPatient.RArea,
mstPatient.RCity,
mstPatient.FamilyId
FROM mstPatient
INNER JOIN SCDoctorList ON mstPatient.InChargeDoctor = SCDoctorList.DoctorID;