Sort comma separated value in SQL Table

  • PSB - Tuesday, December 4, 2018 10:10 AM

    data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAY4AAAAVCAYAAABR0glIAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAqsSURBVHhe7ZzPSxxJFMe/7j+wR3eRScBlEDwoQhBB9mBA9CCCmJMhGBAMCYIgKAhz8DAQMBAQwkqEQETiSRkQD8qAHoIgIgzjQQjDDiRDyM4t/gXZ96qre7p7qrqrZyYTE+oDTXdXV3VXV71X70ePdnwjYLFYLBaLIb/d3Nygo6MDdm/3dm/3dm/3JvuOd4UbG3FYLBaLxZjf5N5isVgsFiOs4bBYLBZLIqzh+FWplFGtyGNLNM2Mla5t0nLL7eO2zdUt6o/ecFT+wdrA73iYzcsCpoyjWSqb/QdVWdJOitlRPKQ+vTmTBTrcvvM2O4ojX/3q2aLv2iKO/BPB7UzeLeL+7cQdD97WdsuyVJZPPsHmJJUH5o+gvr8ZWERRnlZ3a/eobbXrNfJ4k6Wx8b+7t416c1LMhq/JjfvhttXKFB1nVc82IPRefrhP/vHxEzlWfhT317VNWl6H6l18clt3T1Fem4N6nLkrntF9z4LjwPrglWme4VIbxybmiZ7BfQ3oXZPUxsDtn4Ou3E9k25brENFg28j+EFEy7hKuU3v3KNlREx1x9A0iXSrVFtLKEc6v3GPDRbZl5HG534uVwg3m7kQ9m5RkMoehgxu8o7rvslM4X5ATQUK7uQVMedcm8DmTVIgj7t9O6F3WMYWX3IdCAUPHA87k07zkSlyexxqXl9bl+8kFenIVJ3wq6ZzJO+/hbgfPkZ6eQL+87lLdXQdGnqGTT/qey+c628tXvahsOfPRn3HL93Afj8V8iXMaZ0GUTKEb4yNALkYBgqjfy4PHY18eh9GOlR/N/XVtk5YH0L0LydzCW6Re8VhSWzxw5pplQNyTyg9WAI0cunPXP5ymOk9qz6U+bS4A94a76UTzDBfuvzeOjcyTQ/H0Gvene3H+PnlbJTo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y13kObEnLx2GhEF7+mk+LuUjRDOB8jNqldHV9pNJCqJYUH4xZGVbIIro5eM6/r7j59+ENPJ0Hcm5KKPMBQ9MIprJC+ftwakR//9A48L01eX9n0fQLinlbl+L2Kkp4i3XZD96EJ0FzNSVyl6NY4zFNr9CYykY6KrSwjEXUizUMnHIko+9FcwZoZYoVw1SIG4GdFSk32rHy1dGha5u03ORZ7OS8cuWW28qP2pynlrK4tHCN++4vpPx4c1dGkRbpR5wOlpc8uaPIoqp7hpYk86ReGIUeUPk9inycNO0oDk/lRblmVBakTlB0Sk5xHTo90OqHj7bqUBTKtiZyqsNApkxkRwP/hNj+k0OieJZH/7B51PFTwH9lSsrX2YggK+BI6/BuPmYxaQHkCa2dTmDNKCXVIpoZK13bpOXfke8yd22eJ/5DxSV6nlmqskX8gLmK5Bb1xyzi+MX55YwGQ5FbKwWsc2YFOI1JnzVNGUfkcbb9l1DNjJWubdLy70jr56498+T/q26O7JOklFvCD5irSG5Rf2zEYbFYLJZE2IjDYrFYLImwhsNisVgsifn29etXTlfZvd3bvd3bvd3H7L9++x84jn21aQ7S6wAAAABJRU5ErkJggg==

    Your database isn't in compatibility mode 120 or lower is it? (although, you'll need 140+ for STRING_AGG)

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • PSB - Tuesday, December 4, 2018 10:10 AM

    data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAY4AAAAVCAYAAABR0glIAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAqsSURBVHhe7ZzPSxxJFMe/7j+wR3eRScBlEDwoQhBB9mBA9CCCmJMhGBAMCYIgKAhz8DAQMBAQwkqEQETiSRkQD8qAHoIgIgzjQQjDDiRDyM4t/gXZ96qre7p7qrqrZyYTE+oDTXdXV3VXV71X70ePdnwjYLFYLBaLIb/d3Nygo6MDdm/3dm/3dm/3JvuOd4UbG3FYLBaLxZjf5N5isV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xaQHkCa2dTmDNKCXVIpoZK13bpOXfke8yd22eJ/5DxSV6nlmqskX8gLmK5Bb1xyzi+MX55YwGQ5FbKwWsc2YFOI1JnzVNGUfkcbb9l1DNjJWubdLy70jr56498+T/q26O7JOklFvCD5irSG5Rf2zEYbFYLJZE2IjDYrFYLImwhsNisVgsifn29etXTlfZvd3bvd3bvd3H7L9++x84jn21aQ7S6wAAAABJRU5ErkJggg==

    What is the compatibility level of the database you are working in?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZUAAAAcCAYAAACpkyKfAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAfUSURBVHhe7Z3PbxNHFMe/7V+QM0KVY0occapC5AOKkDC1HSnBwoccWlAbKRzsHqzlEEguQXAJPw5YPtSuRKSkClw4uHISqY5JIqGqB8vJ0cJpa6yq6tn/QTtvdnaz3uz6R7KYhLyPWNid2Xnz1oL3nfdmTT5rNpv/gWHOMFtbW+qMYZjjwqLCMAzDeMbn6k+GYRiGOTYsKgzDMIxncPmLOfP8VPhdnTEMc1xYVJgzD4nKN6Gv1BXDMMeBy18MwzCMZ7CoMAzDMJ7BosIwDMN4BosKwzDONBr06+Rw0vxhHHEVlXpWQ2RgAAN0RCLQSnXV85GoZxGJZOHqRaf+dhxnrBNe22P6T+MF4ufP4Qs6bsawtK3aBY3te5a+e1iyBjoad/MFOsa+Nvb7yc79mO6DOOKWB5HtYyncHRPt923OCd/nzt/Djrok3Oy0so25+5bPxsGOxM1+iz8NLN13GMt8dBxFpZ6NYCQfwOxeE82mOHKzwFQC2X5FSWtQ7lVMjGsO7MyREcFvrIDJ3/7F3/+IIx3D+ncqgAlBuZsBUmbfOP7QhCh0VBErbez3E/Es3yOGt+TDP79jcu0K5mS8foFMjdoLyFN7La2eTwTym0I4xhbwii4N3OzYaCylgeg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EwVuxC4B/CZXOPqIF6bRQX2/1Dc7NjwS4MPdHGHxaYk4dj+cuf3MRevIZnZlnnGfA6J1bsfiRzixAdsn0kH8deusvdgmAVtYRu72BcGLKqpOZJ5Kv6vf4vpXiNHNrgroqgbrfhwiEbYUwI/QoaguAIPd9rckh/7kQN8dzBvg6V3Ej14qYqtb9fhzfqTxu+mQxWRCZwVW6Kn8PVDLCSVgEz9BTPU0DGKDNp+5i8hdbyWGXBHCsP2/c83O3rey1Yu3Jg25jXhu96TMwDTB68Qtb1WIOd7AJ2sYrvlR90yO+Y+O4gFSD/Yoifv4L1gIaZNoZc7VihbOzlr0d7U8vVHxKY2+qNMuak0J//pZhW8Akg91Ff9RXBPbKBiU3eNGda8eJ/Kd7Z3sa10CcW3egb7CR17ZSpByhDyw0W8PioH5PdH/oSanEc+SesKieJHt/+OqWUNJFJTKEaT7GgMB+ET05QCBG9vRIUwjejAcUOJbl2tPjTwFIRSLGgnDj456kwZx7+eSoM4x1nI1NhGIZh+gKLCsMwDOMZXP5izjz8M+oZxjtYVBiGYRjP4PIXwzAM4xksKgzDMIxHAP8De5NlHSpi8bYAAAAASUVORK5CYII= . Set at 110

    So now you understand the problem, I presume?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • If I change it to 140, will there be any implications ?

    Thanks,
    PSB

  • PSB - Tuesday, December 4, 2018 10:32 AM

    If I change it to 140, will there be any implications ?

    Thanks,
    PSB

    Of course. It will be treated as a 2017 database rather than a 2012 database. The new cardinality estimator will kick in. New features and functions will be available to you. Do not do this on a production system you care about until you have performed testing.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • All right, I have changed the compatibility level to 140 for my database .

    I have different Line items for Country column
    Astrakhan, Azerbaijan, Kazakhstan, Russia Land, Sakhalin, Uzbekistan, Turkmenistan
    Astrakhan, Sakhalin
    Azerbaijan, Kazakhstan, Turkmenistan, Uzbekistan

    With this code:

    ;WITH Split (Value)

    AS

    (

    SELECT DISTINCT Country

    FROM [dbo].[Table] YT CROSS APPLY STRING_SPLIT(REPLACE([Country], ' ', ''), ',') ss

    )

    SELECT STRING_AGG(Split.Value, ', ') WITHIN GROUP (ORDER BY Split.Value)

    FROM Split;

    I get all values in one row :
     Astrakhan, Azerbaijan, Kazakhstan, Russia Land, Sakhalin, Turkmenistan, Uzbekistan,  Astrakhan, Sakhalin,  Azerbaijan, Kazakhstan, Turkmenistan, Uzbekistan, Argentina, Bolivia, Argentina, Bolivia, Brazil, Chile, Astrakhan, Azerbaijan, Kazakhstan, Russia Land, Sakhalin, Turkmenistan, Uzbekistan, Azerbaijan, Brazil, California, Canada Land, Houston, Midcontinent, Northeast, Rockies, South Texas, Southeast, West Texas, Colombia, Ecuador, Colombia, Peru, Ecuador, Kazakhstan, Kazakhstan, Uzbekistan , LAN HQ, LAS HQ, Sakhalin, Turkmenistan

    Thanks,
    PSB

  • PSB - Tuesday, December 4, 2018 10:38 AM

    All right, I have changed the compatibility level to 140 for my database .

    I have different Line items for Country column
    Astrakhan, Azerbaijan, Kazakhstan, Russia Land, Sakhalin, Uzbekistan, Turkmenistan
    Astrakhan, Sakhalin
    Azerbaijan, Kazakhstan, Turkmenistan, Uzbekistan

    With this code:

    ;WITH Split (Value)

    AS

    (

    SELECT DISTINCT Country

    FROM [dbo].[Table] YT CROSS APPLY STRING_SPLIT(REPLACE([Country], ' ', ''), ',') ss

    )

    SELECT STRING_AGG(Split.Value, ', ') WITHIN GROUP (ORDER BY Split.Value)

    FROM Split;

    I get all values in one row :
     Astrakhan, Azerbaijan, Kazakhstan, Russia Land, Sakhalin, Turkmenistan, Uzbekistan,  Astrakhan, Sakhalin,  Azerbaijan, Kazakhstan, Turkmenistan, Uzbekistan, Argentina, Bolivia, Argentina, Bolivia, Brazil, Chile, Astrakhan, Azerbaijan, Kazakhstan, Russia Land, Sakhalin, Turkmenistan, Uzbekistan, Azerbaijan, Brazil, California, Canada Land, Houston, Midcontinent, Northeast, Rockies, South Texas, Southeast, West Texas, Colombia, Ecuador, Colombia, Peru, Ecuador, Kazakhstan, Kazakhstan, Uzbekistan , LAN HQ, LAS HQ, Sakhalin, Turkmenistan

    Thanks,
    PSB

    Try changing SELECT DISTINCT Country to SELECT value

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

Viewing 8 posts - 16 through 22 (of 22 total)

You must be logged in to reply to this topic. Login to reply