I have a temp table in Transact-SQL which has 2 columns. I inserted the data into the table with spaces on the right side of the value as shown below
insert into #temp ([ACCESS],[USER_ID]) values ('ABC','MGDinfo ')
There validation query using RTRIM function is not giving the result of these right-side spaced values.
select count(*) from #temp where RTRIM([USER_ID])<>[USER_ID]
“The expected result of the above query should be 1 row. Whereas the query is giving 0 records.
I tried displaying the same by directly mentioning the space in value as shown in below query and it is showing that 1 row:
select [ACCESS],[USER_ID] from #temp where [USER_ID]='MGDinfo '
I also tried the similar steps for LTRIM and it is working fine whereas the same is not working with RTRIM”