Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

how to get comma seperated values for a single column

$
0
0

Hi all,

I have procedure which has cols like scopeid ,sprintname ,sprintid,highlevelitem,etc

now,if suppose 1 scopeid there are 5 highlevel items and in that 3 highlevelitems have 1sprintname(sp1) and other 2 highlevelitems has other sprintname(sp2)..

now in my procedure i implemented logic coalesce() to get sprintnames as commaseperated for single scopeid..

but the problem is when i implemented coalsce() i'am getting all sprints for single scopeid..in my db for many scopeid's i have only 1 sorintname....but my logic returns output as singlescopeid with mutliplesprints and this is same for all scope's in a project

(actually project has multpile scope's)..

please help me to get appropriate sprint for scopeid and comma seperated values should come correctly..

my coalesce() is:

STUFF((
SELECT COALESCE(CHAR(10)+CONVERT(VARCHAR,SPP.Name )+',', '') 
FROM	Sprint SPP LEFT JOIN sprint_tasks SPT on SPP.sprintid=SPT.sprintid AND SPT.sprintscopeid=SP.scopeid
where SPP.ProjectID =SP.ProjectID FOR XML PATH('')), 1, 1, '') as SprintName


lucky


Viewing all articles
Browse latest Browse all 12963

Trending Articles



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