I have strings in a database table like this:
Peter/Parker/Spiderman/Marvel
Bruce/Wayne/Batman/DC
Is there a way in SQL to extract specific values from a string e.g.
Name = MyColumn(0)
SurName = MyColumn(1)
Character = MyColumn(3)
Company = MyColumn(4)
Thanks
If you know you will have exactly 4 columns, then you can also use this nested CTE version:
See SQL Fiddle with Demo
The result is:
Or you can implement both a CTE that splits the data and then a
PIVOT:See SQL Fiddle with Demo