SQL SERVER 2005 : Using Special Characters (Wild Characters) in LIKE And NOT LIKE Operator

Special Characters are used for finding a specific character string using the LIKE operator in SQL SERVER.


Special Characters are used for finding specific character string using LIKE operator in SQL SERVER.

Let's start to create the database - trail

Table - Faculty

Insert records

Untitled-1.gif

Select * from Faculty

Shows all records within the table.

Untitled-2.gif

LIKE 'V[%]' : Searches for strings starting with the "v" character.

Untitled-3.gif

LIKE '[_]n' : Searches for strings starting with any character, but the second character must be 'a' character.

Untitled-4.gif

LIKE 'ra[d]' : Searches for strings starting with "ra" but after "ra" there must be a "d" character.

Untitled-5.gif

NOT LIKE 'ra[d]' : Searches for strings not starting with "ra" or after "ra" there is not a "d" character in the string.

Untitled-6.gif

There are several patterns for searching strings.