Posted By

rengber on 03/19/08


Tagged

sql StringHandling Subquery


Versions (?)

TSQL to Concatenate Subquery Row Values into a Column Value


 / Published in: SQL
 

  1. ( SELECT SA.AttributeName + ':' + SAV.AttributeValue + ', <br>'
  2. FROM Core.ProductAttributeValue PAV
  3. JOIN Core.AttributeValue SAV ON SAV.AttributeValueId = PAV.AttributeValueId
  4. JOIN Core.Attribute SA ON SA.AttributeID = SAV.AttributeId
  5. WHERE PAV.ProductID = P.ProductId AND PAV.Version = P.Version
  6. FOR XML PATH('')) AS Attributes,
  7.  
  8. --Simple Version
  9. (
  10. SELECT T.ColToConcat + ","
  11. FROM SubqueryTable T
  12. WHERE T.Id = MainQuery.Id
  13. FOR XML PATH('')
  14. ) AS Concat

Report this snippet  

You need to login to post a comment.