Ravi Yenugu
Ravi Yenugu

Reputation: 3898

Does number of wildcard characters(specially %) matter in SQL Like Statement?

A question regarding the use of % in T-SQL Like statement

I was reading this question on SO and was puzzled to see 3 % in a like statement

I initially thought they mean the same , i.e. using

select * from Tbl where name like 'Abc%'

and

select * from Tbl where name like 'Abc%%%'

I just need to know if they are different and how?

Upvotes: 1

Views: 95

Answers (1)

DrCopyPaste
DrCopyPaste

Reputation: 4117

No it does not.

See the list of special characters on that site (copying from the link, paragraph "Arguments"):

 % Any string of zero or more characters.

 _ (underscore) Any single character. 

On a side note: SQL Fiddle is really neat for testing this kind of small things if you don't have a SQL Server Management Studio available.

EDIT: sry just saw you already linked that page in your question, but the behavior of those wildchard characters actually matches exactly what that page states about their behavior.

Upvotes: 3

Related Questions