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……

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: