Skip to content

Instantly share code, notes, and snippets.

@AlexArchive
Created July 29, 2013 10:48
Show Gist options
  • Save AlexArchive/6103538 to your computer and use it in GitHub Desktop.
Save AlexArchive/6103538 to your computer and use it in GitHub Desktop.
Working with the LIKE predicate
-- The % (Percent) Wildcard
SELECT empid, lastname
FROM HR.Employees
WHERE lastname LIKE N'D%';
-- The _ (Underscores) Wildcard
SELECT empid, firstname, lastname
FROM HR.Employees
WHERE firstname LIKE N'___a';
-- The [<List of Characters>] Wildcard
SELECT empid, lastname
FROM HR.Employees
WHERE lastname LIKE N'[ABC]%';
-- The [<Character>-<Character>] Wildcard
SELECT empid, lastname
FROM HR.Employees
Where lastname LIKE N'[A-C]%';
-- The [^<Character List or Range>] Wildcard
SELECT empid, lastname
FROM HR.Employees
WHERE lastname LIKE N'[^A-C]%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment