Database Reference
In-Depth Information
Figure 5-8.
Using the
LIKE
operator with
%
How It Works
You specify three columns of the Address table.
select AddressID, AddressLine1, City
from Person.Address
You specify the
WHERE
clause with a pattern using the
LIKE
operator to list all cities that begin with
the letter
R
and that consist of any number of letters after that.
where City like 'R%'
Try It: Using the Underscore (_) Character
To see how the underscore (
_)
wildcard character works, open a New Query window in SQL Server
Management Studio. Enter the following query, and click Execute. You should see the results shown in
Figure 5-9.
Select AddressID, AddressLine1, City
from Person.Address
where City like 'S______' -- S followed by 6 underscores