Database Reference
In-Depth Information
Figure 5-9. 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 S and consist of a maximum of six letters after that, for example Seattle, Spokane, Shawnee,
and so on.
where City like 'S______'
Try It: Using the Square Bracket ([]) Characters
To see how the [] characters work in pattern matching, 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-10.
Select AddressID, AddressLine1, City
from Person.Address
where City like '[B,R,S]%'
Order by City Asc
 
Search WWH ::




Custom Search