Click to See Complete Forum and Search --> : Drop the last charector of a string?


ccrookston
08-07-2006, 11:07 AM
In MS SQL, how would you drop the last character of a string?

SELECT
main_heading,
LEFT(sub_heading,len(sub_heading)-1) AS sub_heading
FROM temp_headings

That query errors out. It doesn’t like the -1, which is really annoying.

SELECT
main_heading,
replace(sub_heading,right(sub_heading,1),'') AS sub_heading
FROM temp_headings

That query replaces all instances of the last character, and not just the last character itself.

??????????

Any advice would be great!!!

Marin
08-10-2006, 07:54 PM
What is the error that you get with Left() function?