I have a single column with string value as:
[04/11/2023,"New addition","","new additional of fund","This, Adam, Kyle","5.00","11147474"]
In this value, there are 7 commas, which is like 7 columns that need to be extracted. Some values can have a comma withing the actual value, but those are wrapped with double quotes.
How to do I extract these values into separate column?
[04/11/2023], [New addition], [NULL], [new additional of fund], [This, Adam, Kyle], [5.00],[11147474]
This seems simple enough but can't figure out how to do in sql.
2条答案
按热度按时间pbossiut1#
Your data sample resembles JSON.
That's why we can convert it into a legit JSON, and easily tokenize it after that into separate columns.
It will work starting from SQL Server 2016 onwards.
SQL
Output
fumotvh32#
You can use this script: