Home Split files using SQL
Reply: 0

Split files using SQL

user1135
1#
user1135 Published in July 17, 2018, 7:57 am

This is my first time posting a question, so please bear with me for any errors. I am trying to Split the numeric values with a delimiter of ';' using sql into separate columns, i was able to achieve splitting part of it using the code below but i will like to split the rest of it within column 3 to separate columns I have a table like this

ID    catalogNumber    STEPID1
----------------------------
815326  FBRS415    499023;499027;726203
with tmp(catalognumber,stepid1_split,stepid1) as (
select catalognumber,cast(LEFT(stepid1, CHARINDEX(';',stepid1+';')-1) as varchar),cast(STUFF(stepid1, 1, CHARINDEX(';',stepid1+';'), '') as varchar)
from EXACT_MATCH
union all
select catalognumber, cast(LEFT(stepid1, CHARINDEX(';',stepid1+';')-1) as varchar), cast(STUFF(stepid1, 1, CHARINDEX(';',stepid1+';'), '') as varchar)
from tmp
where stepid1> ''
)
select *
from tmp
ID     catalogNumber    STEPID1    STEPID2    STEPID3
---------------------------------------------------
815326   FBRS415         499023      499027      726203
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301769 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO