[thelist] SQL Question - Drop the last charector of a string

Casey Crookston caseyc at IntelliSoftmn.com
Mon Aug 7 11:17:08 CDT 2006


Got it! A co-worker provided the clue:

SELECT 
main_heading,
case when isnull(sub_heading, '') = '' then '' else left(sub_heading,
len(sub_heading)-1) end as sub_heading
FROM temp_headings
ORDER BY main_heading, sub_heading

The problem with len(sub_heading)-1) is that sub_heading is often NULL.
Thus the error.

Thank you for your help!

Casey




More information about the thelist mailing list