Skip to content

Instantly share code, notes, and snippets.

@dcs619
Last active September 28, 2015 16:39
Show Gist options
  • Select an option

  • Save dcs619/f010eb841fb3122d86c1 to your computer and use it in GitHub Desktop.

Select an option

Save dcs619/f010eb841fb3122d86c1 to your computer and use it in GitHub Desktop.
delimited Parse
-- Get a list of Member Id's and their schedules
SELECT EntityId, r.value('.', 'varchar(255)') AS Schedule
FROM (
-- create valid xml path
SELECT EntityId, CAST('<n>' + REPLACE(Value, ',', '</n><n>') + '</n>' AS XML) AS 'Schedules'
FROM AttributeValue
WHERE Id = 1257002
) AS baseXML
-- parse the xml into a table
CROSS APPLY Schedules.nodes('n') AS parse(r)
@dcs619
Copy link
Copy Markdown
Author

dcs619 commented Sep 28, 2015

translates this:
"5732FFF2-D1B0-4B6A-9303-5C3117C2EEA2,A3FF47F0-BCFF-4BA8-872A-273C5CEAF892,62BA8A23-CED4-41B6-8DF3-7CAFE5A85591,E3B80EB4-55F9-4E04-98F2-F1D5FB3462DF"

into this:
5732FFF2-D1B0-4B6A-9303-5C3117C2EEA2
A3FF47F0-BCFF-4BA8-872A-273C5CEAF892
62BA8A23-CED4-41B6-8DF3-7CAFE5A85591
E3B80EB4-55F9-4E04-98F2-F1D5FB3462DF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment