Link to home
Start Free TrialLog in
Avatar of aneilg
aneilgFlag for United Kingdom of Great Britain and Northern Ireland

asked on

CHARINDEX

i have the following query but its returing the worng results.

current
server\fred.potatoe

    , RunBy = SUBSTRING(el.UserName,2,CHARINDEX('\',el.UserName,2)-2)
returns
server

i want to retunn fred.potatoe
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
SOLUTION
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
Avatar of Sean Stuber
Sean Stuber

The subtraction will work, but isn't necessary

substring works fine if you over-read,  it'll simply read until the end of string and stop
It's just useful to show how to target the exact position of characters.
Avatar of aneilg

ASKER

thanks guys.