SQL Server Interview Question #48

What is LIKE used for?

SELECT, Filtering, Sorting & Built-in Functions Mid-Level Intermediate

Detailed Explanation

LIKE performs pattern matching on character data. The percent sign (%) represents zero or more characters, while underscore (_) represents one character.

Whether comparisons are case-sensitive depends primarily on the applicable collation. Patterns beginning with a wildcard, such as '%camera', often make efficient index seeking more difficult than prefix searches such as 'camera%'.

Code Example

SELECT Id, Name
FROM dbo.Products
WHERE Name LIKE N'Dash%';