How to apply trim function inside this query

78 views Asked by At

Below is simple sql query to select records using in condition.

--like this I have 600 usernames
select * from tblUsers where Username in ('abc  ','xyz  ',' pqr  ',' mnop  ' );

I know there are LTrim & Rtrim in sql to remove the leading trailing spaces form left & right respectively.

I want to remove the spaces from left & right in all the usernames that I am supplying to the select query.

Note:- I want to trim the values that I am passing in the in clause.(I don't want to pass LTrim & RTrim to each value passed).

How to use the trim function in the select query?

I am using MS SQL Server 2012

0

There are 0 answers