Perhaps I've been at this for a few too many hours, but there is something very odd about the results of this statement.

The result of this statement

> 
> (1) datalength(rtrim([last name])) as
>  last\_name\_length
> 
> 
> 

is 10.

The result of the next statement, which I want to use for padding the last\_name column with spaces,

> 
> (2) datalength(REPLICATE(' ', (30 -
>  datalength(rtrim([last name])))))
> 
> 
> 

is 20.

You would think that the result of this statement,

> 
> (3) datalength(rtrim([last name]) +
>  REPLICATE(' ', 30 -
>  datalength(rtrim([last name]))))
> 
> 
> 

would be 30.

It isn't. It's 50. The result of statement (3) is consistently greater than that of statement (2) by 30. It's as if I'm using a + operator in the REPLICATE statement instead of a -.

I've Googled this again and again and I don't see what's wrong with the syntax. Any help will be appreciated.