Saturday, October 23, 2010

SQL LEN function

Well, i was having an issue comparing a string retrieved from sql server and user input, the comparsion was always failing, wonder why, after debugging i found that the value in sql server had a space at the end (right), so i fired up ssms and did a LEN() function on the string, the len function result was same as what the user entered, then why was the comparsion failing, after sometime i realized that len function ignores spaces on the right, so then i used the datalength function and it gave me the correct result.

wonder why the LEN function ignores the right white spaces......

No comments: