PeterBaileyUk
asked on
sql server string_split
I am using sql server 2016
I have an sql statement that gives me the rows I need with the words separated by a space.
I now need to split those words, I am trying String_Split
some of my words contain apostrophes or hyphens or + sign so all those need to remain in the word intact hence the space delimiter is perfect.
i am not sure how to merge this sql to do the split.
the concat has to remain as the 3 fields in the first select statement provide the vehicle data.
The split words will be sent to a destination table of words
the output from the first query is like this:
I have an sql statement that gives me the rows I need with the words separated by a space.
use Dictionary
GO
SELECT [MVRIS CODE], CONCAT([Model Range], CHAR(32), [RANGE SERIES], CHAR(32), [VARIANT]) AS ConCatDesc, MARQUE
FROM ClientData.[dbo].SMMT;
I now need to split those words, I am trying String_Split
some of my words contain apostrophes or hyphens or + sign so all those need to remain in the word intact hence the space delimiter is perfect.
i am not sure how to merge this sql to do the split.
SELECT value
FROM STRING_SPLIT(CONCAT([Model Range], CHAR(32), [RANGE SERIES], CHAR(32), [VARIANT],CHAR(32))
the concat has to remain as the 3 fields in the first select statement provide the vehicle data.
The split words will be sent to a destination table of words
the output from the first query is like this:
MVRIS CODE ConCatDesc MARQUE
P7AKR IBIZA MK3 FL (Typ 6L) (SE240) REFERENCE 12V SEAT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
SELECT SMMT.[MVRIS CODE], SMMT.MARQUE, s.value AS [Word]
FROM ClientData.[dbo].SMMT SMMT
CROSS APPLY STRING_SPLIT(CONCAT(SMMT.[Model Range], CHAR(32), SMMT.[RANGE SERIES], CHAR(32), SMMT.[VARIANT]), CHAR(32)) s
ASKER
I had to alter it slightly but it worked after i moved the closing argument of the concat. thank you
ASKER