Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
swatib
Posting Yak Master
173 Posts |
Posted - 2006-09-19 : 05:46:29
|
i have a queryACTIVITY- SUBACTIVITYA-A1A-A2A-A3B-B2expected Result :A-A1,A2,A3B,B2Njoy Life  |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-19 : 05:50:29
|
See this topic http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=53293And if you don't get it, try thisCREATE FUNCTION dbo.ConcatRows( @Activity VARCHAR(10))RETURNS VARCHAR(8000)ASBEGIN DECLARE @Output VARCHAR(8000) SELECT @Output = COALESCE(@Output+', ', '') + CONVERT(VARCHAR(20), at.SubActivity) FROM ActivityTable at WHERE at.Activity = @Activity ORDER BY at.AubActivity RETURN @OutputENDGoSELECT DISTINCT Activity, dbo.ConcatRows(Activity)FROM ActivityTable Peter LarssonHelsingborg, Sweden |
 |
|
swatib
Posting Yak Master
173 Posts |
Posted - 2006-09-19 : 08:25:46
|
what is the @Activity in the function?Njoy Life |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-19 : 08:33:47
|
@Activity is the parameter used to concat your data.You send the first column to the function and name it @Activity in the function.Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|