Using Transact-SQL Wildcard Operators

The concept of using wildcard conditions in SQL was introduced on Day 3, “Expressions, Conditions, and Operators.” The LIKE operator enables you to use wildcard conditions in your SQL statements. Transact-SQL extends the flexibility of wildcard conditions. A summary of Transact-SQL's wildcard operators follows.

  • The underscore character (_) represents any one individual character. For example, _MITH tells the query to look for a five-character string ending with MITH.

  • The percent sign (%) represents any number of characters, including zero characters. For example, WILL% returns the value WILLIAMS if it exists. WILL% returns the value WILL.

  • Brackets ([ ]) allow a query to search for characters that are contained ...

Get Sams Teach Yourself SQL in 21 Days, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.