Click here to Skip to main content
15,860,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
id   name    marks
1    sh      20,50,40,63
2    an      20,50,90,93
3    is      20,70,40,63
4    an      20,60,40,93
4    ri      20,40,60,73


i need below result which query do i need to use

id    name    marks    marks2
1     sh      20       50
2     an      20       50
3     is      20       70
4     an      20       60
4     ri      20       40


What I have tried:

SQL
select
  PATINDEX('%,%',marks),
  LEFT(marks , PATINDEX('%,%',marks) - 1),
  STUFF(marks, 1, PATINDEX('%,%',marks), '')
from xyz
Posted
Updated 5-Dec-16 19:15pm
v3

1 solution

 
Share this answer
 
Comments
Karthik_Mahalingam 6-Dec-16 12:35pm    
5
Peter Leow 6-Dec-16 19:15pm    
Thank you, Karthik.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900