Monday, February 20, 2012

ltrim and rtirm is not working

Hi i have a select statement as

select empnum, len(empnum), ltrim(rtrim(empnum)), len(ltrim(rtrim(empnum))) from employee

When i execute this stament i get the following

1234 6 1234 6
4321 8 4321 8
1111 6 1111 6
2222 6 2222 6

How does this happens. Why ltrim and rtrim is not working here.what are you using to display these results, query analyser? enterprise manager? something else?

the length of 1234 is clearly not 6|||What does this yield:

select 'X' + ltrim(rtrim(empnum)) + 'X' from employee|||Ive got it, the input statement is from vb.net source, and the programmers have stored vbcrlf after each string. char(13) stored at the end and that is the reason y ltrim and rtrim is not working.

I removed the char(13) at the end and now it is working.

Thanks for your time

No comments:

Post a Comment