June 4, 2005 at 4:06 am
When I retrieve a data from a query, eg the max value in a table, i have found out that on the left there are blank spaces.
If @result is the word good
and I print on query analyzer:
print @result + 'bananas'
I see:
good bananas
I tried to remove them using the functions:
RTRIM, LTRIM and LEN, and LEFT:
set @result = LTRIM(RTRIM(@result))
and also
set @result = LEFT(@result,LEN(LTRIM(RTRIM(@result))))
but anything change and the blank spaces are not removed......
any help
thank
June 4, 2005 at 4:30 am
Guess you've tried the replace function..
eg REPLACE(table.field, CHAR(32), '')
where CHAR(32) is a space...
June 4, 2005 at 6:35 am
Hi the problem is that you have extra spaces to the right of good. Use rtrim. HTH Mike
declare @word char(50)
declare @anotherword char(50)
set @word ='good'
set @anotherword ='apple'
Set
print rtrim(@word) + ltrim(@anotherword)
/* return goodapple*/
print rtrim(@Word) + @anotherword
/*returns goodapple*/
print rtrim(@word) + char(32) + @anotherword
/*returns good apple*/
June 5, 2005 at 6:53 am
Use Varchar instead !
Declare
@frstpart varchar(50),
@Extrpart varchar(50)
Select @Frstpart='Good',@Extrpart='bananas'
Print @Frstpart+space(1)+@Extrpart
June 5, 2005 at 7:05 am
If at all possible the datatype on that field should be changed to varchar so you don't have to rtrim each time!
**ASCII stupid question, get a stupid ANSI !!!**
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply