Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

Join with a SQL Server STUFF

My code below works...
But In my output I need to include the OriginID Column
So... I would have OriginID       OriginName in theoutput

THIS
    SELECT STUFF(( SELECT  ',' + OriginName
                    FROM    Origins o
                            JOIN dbo.PromotionLeadFormsToOrigins po ON po.OriginID = o.OriginID
                    WHERE   po.PromotionLeadFormID = 10
                  FOR
                    XML PATH('')
                  ), 1, 1, '')  AS OriginName;

Open in new window


PRODUCES THIS
OriginName
BOSTON GLOBE TRAVEL SHOW,DREAMS DO COME TRUE


In Need this
OriginID       OriginName
10                  BOSTON GLOBE TRAVEL SHOW,DREAMS DO COME TRUE
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Larry Brister

ASKER

Perfect
Thanks
& thanks for the quick close/feedback - much appreciated
cheers, Paul
Working on a Saturday... and now I can go home. Thanks
"avagoodweekend" (an aussie way of saying it, it's already Sunday for me)