sql server equality operator will not work with strings with trailining spaces


Hi All,

sql server equality operator will not work with strings with trailining spaces.

below is the script for this. Please check at your end using query explorer

it will work fine for the leading space strings also

declare @string varchar(100)

set @string=’mssqlbuzz’

select len(@string) as [string without spaces]

set @string=’mssqlbuzz ‘

select LEN(@string) as [string with trailing spaces]

set @string=’ mssqlbuzz’

select LEN(@string) as [string with leading spaces]

result:

Regards,

Chaitanya

Visit site: https://mssqlbuzz.wordpress.com

Send an Email : mssqlbuzz

Leave a comment

Design a site like this with WordPress.com
Get started