How can I split this particular string in the column to three different column
sample:
Column_A
----------
{"nationalCode":"1234567893","username":"123","ip":"::1"}
{"nationalCode":"1234567892","username":"test","ip":"172.30.10.11"}
{"nationalCode":"1234567890"}
{"nationalCode":"1234567891","username":"test"}
should be
nationalcode|username|Ip
---------------------------
1234567893 |123 |::1
1234567892 |test |172.30.10.11
1234567890 |null |null
1234567891 |test |null
what I have tried so far for just one of the field is(I have no Idea how to solve it)
select SUBSTRING(REPLACE(SUBSTRING(ActionInput,CHARINDEX('nationalCode',ActionInput)+len('nationalCode":"'),CHARINDEX(',',ActionInput)),'""',''),0,11) as national1,
REPLACE(SUBSTRING(ActionInput,CHARINDEX('username',ActionInput)+len('username":"'),CHARINDEX(',',ActionInput)),'"}','') as a
from LogTBL