Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Issue in SSRS while using XML PATH in SQL query

$
0
0

Hi All,

  I have used a SQL query which concatenates multiple rows into one single row seperated by a coma.

 

select NoteID, STUFF(
	(SELECT ',' + a.Comments AS [text()]
	from Notes a
	where a.NoteID = b.NoteID
	Order by a.Comments
	for xml PATH('')),1,1,''	) AS Comments_Concatenated
 from Notes b
group by NoteID
ORDER BY NoteID

Here I have a Note ID and Comment Column

Note ID          Comment

100                  Text 1

100                  Text 2 

101                  Text 3 

101                  Text 4

By using the above query , when i run it in SQL management studio I get

NoteID            Comment

100                 Text1,Text2

101                 Text3,Text4

However when i use the same query in SSRS query designer I get the reuslt as

Note ID          Comment

100              <Expr>Text1 </Expr>,<Expr>Text2</Expr>

101              <Expr>Text3 </Expr>,<Expr>Text4</Expr>

The additional strings <Expr> are getting added. I think the XML Pathin the query is creating the problem. How do i overcome in SSRS.I want to remove the additional strings <Expr>.

Please let me know how to achieve this in SSRS.

 

Thanks,

Ram


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>