Save up to $499! Grab all Python courses for $49 or all online courses we’ve ever launched for only $169. Only Feb 11-16. Happy Valentine's!
Simple text functions
How to modify Strings


Great! You have completed a simple task using LIKE. However, T-SQL and T-SQL Server provide additional ways to use LIKE. One is with square brackets [ ]. You simply put characters in the brackets and place them where these characters would occur in the string.

Look at the following example:

FROM Copywriter
WHERE FirstName LIKE N'[AM]____' ;

This pattern matches all first names that have A or M as the first letter and any of the next 3 letters.

What about a wildcard character that allows you to exclude one of a given set of characters? In this case, you can use ^ as the first character in the square brackets. In this pattern:


only strings that do not start with A, C, or H will match.

You can also use [] to indicate a range letters or numbers. For example:

  • N'[0-9]': denotes 0,1,2,3,4,5,6,7,8,9
  • N'[b-f]': denotes b,c,d,e,f


Let's find the Ids of items with names that contain at least one digit.

Stuck? Here's a hint!

Use the pattern N'%[0-9]%'.