Does anyone have script that can pull out data held in the columns to split out the servernames in to their own columns?
| ID| Servers
|:-:|---------------------------------------------------------------------------------
| 1 | {"Name":"SQL-Vlfflk43E"}
| 2 | {"Name":"SQL-VgflkglkdA"},{"Name":"SQL-VCkfkjgitrE"},{"Name":"SQL-;bv;b;b"},{"Name":"SQL-kkkbdddb"}
| 3 | {"Name":"SQL-VgkgkgA"},{"Name":"SQL-VfkgkjygtbB"},{"Name":"SQL-lglg"}
| 4 | {"Name":"SQL-VotoevB"},{"Name":"SQL-VCfkjfkjrtrE"},{"Name":"SQL-lglkgl"}
| 5 | {"Name":"SQL-VblgltotA"},{"Name":"SQL-VCfkfkgE"},{"Name":"SQL-lkgkjgkg"}
| 6 | {"Name":"SQL-VCggkgkg"}
So ID 1 & 2 would become like the below? I know char
& patindex
can help just struggling to get my head around it.
| ID| Text | Server1 | Server2 | Server3 | Server4
| 1 | {"Name":"SQL-Vlfflk43E"} |SQL-Vlfflk43E |null |null | null
| 2 | {"Name":"SQL-VgflkglkdA"},{"Name":"SQL-VCkfkjgitrE"},{"Name":"SQL-kkkbvb;b"},{"Name":"SQL-kkkbdddb"}|SQL-VgflkglkdA|SQL-VCkfkjgitrE|SQL-kkkbvb | SQL-kkkbdddb
You may transform the stored data into a valid JSON array and parse it with
JSON_VALUE()
:Result: