Link to home
Start Free TrialLog in
Avatar of vbnetcoder
vbnetcoder

asked on

string fuctions

I have a field (name ratio value) that has data that looks like this 12:64

(ie.  two numbers separated by ":")


How would i break it apart in a select query so everything to the left of ":" is returned as 1 aliased field and everything to the right of ";" is another?
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If right side is always two characters after : then you could simplify the good solution from sdstuber to:

Select Left(@R,charindex(':', @R)-1) As LeftSide, substring(@R,charindex(':', @R)+1, 2) As RightSide From MyTable;

Open in new window

Avatar of Sean Stuber
Sean Stuber

similarly if the left side is always 2 and your right side is always 2 then you can simplify a lot

select left(ratio_value,2) as firstpart, right(ratio_value,2) as secondpart from your table
Avatar of vbnetcoder

ASKER

ty