What is Wildcard character in SQL Server ?

 Posted by Chikul on 12/23/2009 | Category: Sql Server Interview questions | Views: 5142

Wildcard characters Determines whether a given character string matches a specified pattern.
A pattern can include regular characters and wildcard characters.
During pattern matching, regular characters must match exactly the characters specified in the character string. Wildcard characters, however, can be matched with arbitrary fragments of the character string.
Using wildcard characters makes the LIKE operator more flexible than using the = and != string comparison operators.

There are 2 Wildcard characters i.e. '%' and '_'
Any string of zero or more characters.
WHERE title LIKE '%computer%' finds all book titles with the word 'computer' anywhere in the book title.

_ (underscore)
Any single character.
WHERE au_fname LIKE '_ean' finds all four-letter first names that end with ean, such as Dean or Sean.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response