Click to See Complete Forum and Search --> : String Concatenation problem


johnsonlim026
November 5th, 2006, 09:04 PM
I faced the problem where the SQL server fail to concatenate two integer but instead sum up the two integer.My code is as below:

WHILE @counter<=len('@Wh125-Loc1')
BEGIN

if (substring('@Wh125-Loc1',@counter,1)='-' )
BEGIN
set @result='10'
BREAK
END
ELSE
if (isnumeric(substring('@Wh125-Loc1',@counter,1)))=1
BEGIN
set @num= substring('@Wh125-Loc1',@counter,1)
set @num2=@num2+@num
print @num2
END
set @counter=@counter +1


END
Can some one give me an idea on doing this?

hspc
November 6th, 2006, 06:07 AM
How did you declare @num,@num2?
I think you declared them as int
try to use varchar(50) for example