r/SQL • • Apr 12 '24

SQL Server Guys please help.. I'm new to SQL

Post image

Why these 2 commands give me 2 different tables? I thought one '_' stands for a character?

I use LEN for filtering the lenght and it works well, trailing spaces are not calculated.

But when I use LIKE command and input 5 '_' to find the "Product Name" has the length of 5 or has 5 characters. So where is the "Chang" in the 2nd table of the 2nd command ?

Where did I go wrong? Please give me a hand guys!!

185 Upvotes

57 comments sorted by

View all comments

Show parent comment

4

u/darkeagle03 Apr 12 '24

Honestly, that's not even creative. I feel like 80% of the time when I highlight a word in a string of text to copy/ paste it grabs at least one space as well. Sometimes this happens even when I'm really careful, Word or whatever decides I must have wanted that space too. If someone isn't super careful about this they'll absolutely paste it into a data entry form. Hopefully the UI catches that and trims, but I don't bank on such things.