Why does the following return a result when the target column in the where clause is a char(20)?
declare @pallettag varchar(20)
set @pallettag = '168531'
--set @pallettag = @pallettag + SPACE(20 - Len(@pallettag))
select s.ROWID, s.SUBLOTCODE + '*', @pallettag + '*'
from IMSUBLOT as s
where s.SUBLOTCODE = @pallettag
s.SUBLOTCODE is defined as char(20) and I would expect to get a result only if I uncomment the third line where I added the needed spaces.
Trailing spaces are ignored in string comparisons in SQL Server except for expressions on the right in a
LIKEcomparison.Returns