[thelist] SQL Question - Drop the last charector of a string
Casey Crookston
caseyc at IntelliSoftmn.com
Mon Aug 7 09:29:30 CDT 2006
Using MS-SQL, how would one drop the last character in a string of
unknown length? We know that the character is, in this case it's a
dash: - But, it could appear more then once in the string and should
only be replaced with nothing when it is the last character in the
string. Two examples:
"Dealers-" would become "Dealers"
"Main-New-" would become "Main-New"
I'm familiar with the "replace" function: replace(string, 'string to
replace','replacement value'). But this will replace all instances of
the dash, and not just the last.
Any ideas?
Thanks!
Casey
More information about the thelist
mailing list