Skip to content

Instantly share code, notes, and snippets.

@rfay
Created January 21, 2016 22:34
Show Gist options
  • Save rfay/97fa621948fbf1cf3f72 to your computer and use it in GitHub Desktop.
Save rfay/97fa621948fbf1cf3f72 to your computer and use it in GitHub Desktop.
SELECT TOP 1000 pi.SubscriberId,
STUFF((
SELECT ',' + tct.CategoryType + '=' + tc.CategoryDescription
FROM SML_Auth.dbo.TSL_User_Categories tuc
LEFT JOIN SML_Auth.dbo.TSL_Categories tc ON tc.CategoryId=tuc.CategoryId
LEFT JOIN SML_Auth.dbo.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
ORDER BY pi.SubscriberId DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment