When I use a Varchar with spaces it ignores the spaces at the end.
ex:
declare @X varchar(50)
This…
set @X= 'John'
…is the same as…
set @X= 'John '
It considers these to be equal. How can I cause the system to recognize these as different?
Best Answer
Everything is just according the ANSI standard:
Trailing blanks explained:
Here's a well known example of all the cases mentioned above:
Here's some more detail about trailing blanks and the
LIKE
clause.BUT if you want to differ them - you may decide to use
DATALENGTH
function instead ofLEN
, becausewill put you 1 instead of
The solution is