Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 replace string

Author  Topic 

kao_77
Starting Member

1 Post

Posted - 2010-08-25 : 06:06:44
How can I replace the last character in string with another character?

String in text field looks like "102030400" and I want change the last "0" to "_"
so string should look "10203040_"
Thanks.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-25 : 06:10:04
SELECT Col1, LEFT(Col1, LEN(Col) - 1) + '_'
FROM Table1


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-25 : 09:21:46
SELECT STUFF(Col,LEN(Col),1,'_') FROM Table

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -