select id,score1=case charindex('-',score) when 0 then score else left(score,charindex('-',score)-1) end,score2=case charindex('-',score) when 0 then score else substring(score,charindex('-',score)+1,8000) end
from ball
from ball
insert @ select 1,'1' union all select 2,'1-2' union all select 3,nullselect id,case when scroe is null then null when charindex('-',scroe)=0 then scroe else substring(scroe,1,charindex('-',scroe)-1) end as Scroe1,
case when scroe is null then null when charindex('-',scroe)=0 then scroe else right(scroe,len(scroe)-charindex('-',scroe)) end as Scroe2
from @--结果(3 row(s) affected)id Scroe1 Scroe2
----------- ---------- ----------
1 1 1
2 1 2
3 NULL NULL(3 row(s) affected)
from ball
id scroe1 scroe2 start-flag?
非要用sql语句为难自己呢?