Friday, July 13, 2012

Sql server neglects trailing spaces

create table #temp ( a varchar(10) )

insert into #temp values('  a                ')

select COUNT(*) from #temp where a='  a'
select COUNT(*) from #temp where a='a'
first query will return 1
2nd will return 0 as sql server will only ignore trailing spaces

So we can avoid use of RTRIM in many situations .

No comments:

Post a Comment