Link to home
Get AccessLog in
Avatar of toooka
toookaFlag for United States of America

asked on

SQL Replace first character in a string

I have a field called Folder that contains a folder path.
I want to replace the drive letter which happens to be the first character.

Field=Folder
Contents
e:\Program files\Documents\test.txt
e:\Program files\Documents\another.txt
I want to change the e to f
Avatar of sventhan
sventhan
Flag of United States of America image

select replace('e:\Program files\Documents\test.txt','e:','f:') stg
ASKER CERTIFIED SOLUTION
Avatar of sventhan
sventhan
Flag of United States of America image

Link to home
membership
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access
Avatar of racmail2001
please try the following query

SELECT concat("f",substring(folder,2)) FROM your.table WHERE 1
SELECT 'f' + SubString(folder,2,Len(folder)-1)

It will replace ANY first char
Avatar of toooka

ASKER

was described as :e instead of e:
replacing is dangerous because you can have the letter "e" in more places in your string