White space issue with SQL concatenate statement
Posted on 2008-10-15
Ok, hopefully this is an easy one for you. The following is a part of a SQL statement I am running.
LTRIM(RTRIM(LTRIM(RTRIM(ABCHCD) + ' ' + CAST(ABABTX AS VARCHAR(10)) + '' + RTRIM(ABACCD) + ' ' + RTRIM(ABAECD)+ ' ' + RTRIM(ABFXCD) + ' ' + RTRIM(ABDFCD))))
ABFXCD reperesents a field that does not always have a value. If ABDFCD ALSO does not have a value then I have no issues. However if ABDFCD does have a value there are two spaces before ABDFCD instead of one.
100 MORTIER DR 1001 (What I am getting)
100 MORTIER DR 1001 (What I want)
Any suggestions on how to alter the code to make this work?