My aim is to display the person name and all the reason for his absences(concated and displaying in a string).
I am using the following query to display the EmployeeName, ReasonForAbsence. I am having problem with concatenating and Displaying all record specific column called 'AbsenceReason'. The error is Incorrect Syntax near ='. More info about error- its happening for displaying absence reason part.
SELECT
--Displaying Name,
EMP.NAME,
--Displaying Absence Reason
(
SELECT
@AbsenceReasons= @AbsenceReasons + ';' + REASONTEXT
FROM
ABSENCE
WHERE ID=EMP.ID
)
FROM
(
SELECT
*
FROM
Employees
) EMP
What have I missed?
Thank you