Hello all sql expert,
How do I remove the extra space in between texts? Below is my query:
Select Column1 + column2
from Tbl
Result set:
ABCD EFGHIJKLM
Result I need:
ABCD EFGHIJKLM
Thanks all
Hello all sql expert,
How do I remove the extra space in between texts? Below is my query:
Select Column1 + column2
from Tbl
Result set:
ABCD EFGHIJKLM
Result I need:
ABCD EFGHIJKLM
Thanks all
In your post, "Result set" and the "Results I need" look the same, so not clear what you are trying to accomplish.
If you want to remove spaces from the resulting string, you can do the following:
Select REPLACE(Column1 + column2, ' ','')
from Tbl
Hi James,
You are correct.
Here is the result set from query:
ABCD_______________EFGHIJKLM
Here is what the result set I need:
ABCD EFGHIJKLM
I used the underline to represent the space.
Select RTRIM(CAST(Column1 AS VARCHAR(256)) + ' ' + LTRIM(CAST(column2 AS VARCHAR(256))
from Tbl
I arbitrarily picked 256 as the maximum length of the columns for column1 and column2. That may or may not be sufficient depending on the data type of those columns. If they are longer, increase the 256 appropriately.
Thanks James, you are a super sql expert !!!