From the course: Querying Microsoft SQL Server 2022

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Match text with LIKE and wildcards

Match text with LIKE and wildcards - SQL Server Tutorial

From the course: Querying Microsoft SQL Server 2022

Match text with LIKE and wildcards

- [Instructor] When filtering the results of a query based on text values, you can use the equals to comparison operator to find text that exactly matches your criteria. But when you need to find approximate text matches that match a pattern, you'll need to use the like operator. Let's take a look at people names from the database, with a new query that selects the first name column from the Person.Person table. Executing the query shows me over 19,000 first names that are stored in the database. Now if I just wanted to get the list of names that start with the letter A, you can add a where clause that reads where the first name... is like, and in single quotation marks, A percent. The like operator and the percent symbol create a text pattern, and the query returns just the records of all the names that start with a letter A. The percent symbol is called a wildcard, and it acts as a placeholder for any other characters. So…

Contents