October 28, 2022 at 3:40 pm
Hi,
I hope someone can help with an issue I'm facing. Within the database I'm working with there is a Column that holds multiple Values and display descriptions e.g [{"display":"Section1","value":"1"},{"display":"Section2","value":"2"}]
What is the best way to split the column information into multiple columns so I can can have a 2 columns e.g. Value and Display
Value Display
1 Section1
2 Section2
Many thanks in advance
October 28, 2022 at 8:11 pm
You could try OPENJSON and provide the 2 column schema definition
declare @json nvarchar(max)=N'[{"display":"Section1","value":"1"},{"display":"Section2","value":"2"}]';
select oj.[value], oj.display
from openjson(@json)
with(display nvarchar(4000),
[value] int) oj
order by oj.[value];
Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können
November 9, 2022 at 8:44 am
Thank you
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply