I have following table
PreventMaintainance
ID Date
1 2018-12-14
2 2018-12-16
PreventMaintainanceDetail
ID Value
1 9874125
1 8745216
1 7251489
I want following struture
1 9874125,8745216,7251489
I am using following query,where I am getting Incorrect syntax near the keyword 'as'..How I will resolve this??
Select
parts=STUFF(
(SELECT ',' + t2.Value
FROM PreventMaintain t1 inner join PreventMaintainanceDetail t2 on
t1.Id = t2.Id
FOR XML PATH ('')
)
, 1, 1, '') as value,pm.Date
from dbo.PreventMaintain pm inner join dbo.PreventMaintainanceDetail pd
on pm.Id=pd.Id
Suraj KumarPosted Dec 14, 2018, 12:26 AM
Priyanka KumariPosted Dec 14, 2018, 12:23 AM
Suraj KumarPosted Dec 14, 2018, 12:08 AM
Madan ShekarPosted Dec 14, 2018, 12:04 AM