Skip to content

Instantly share code, notes, and snippets.

@rfay
Created January 16, 2016 21:13
Show Gist options
  • Save rfay/0810f622891f8c29df68 to your computer and use it in GitHub Desktop.
Save rfay/0810f622891f8c29df68 to your computer and use it in GitHub Desktop.
SELECT TOP 100 pi.SubscriberId,
STUFF((
SELECT ',' + tct.CategoryType + '=' + tc.CategoryDescription
FROM TSL_User_Categories tuc
LEFT JOIN TSL_Categories tc ON tc.CategoryId=tuc.CategoryId
LEFT JOIN TSL_CategoryTypes tct ON tc.CategoryTypeId=tct.CategoryTypeId
WHERE pi.SubscriberId=tuc.SubscriberId
FOR XML PATH('')),1,1, '') AS categories
FROM TES_Connect_SML.dbo.TES_PROFILE_PERSONALINFORMATION pi
GROUP BY pi.SubscriberId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment