TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Priyanka Kumari
NA
88
24.2k
concatenate multiple rows into one row in sql server
Dec 13 2018 11:41 PM
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
Reply
Answers (
4
)
Concept of Tuples
values are not updating after clicking of save button