Skip to content

Latest commit

 

History

History
63 lines (52 loc) · 2.39 KB

percent-character-wildcard-character-s-to-match-transact-sql.md

File metadata and controls

63 lines (52 loc) · 2.39 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic ms.custom f1_keywords helpviewer_keywords dev_langs monikerRange
Wildcard search (%)
Percent character (Wildcard - Character(s) to Match) (Transact-SQL)
rwestMSFT
randolphwest
12/19/2022
sql
t-sql
reference
ignite-2024
%
%_TSQL
wildcard
conditions [SQL Server], wildcards
% (wildcard - character(s) to match)
matching conditions [SQL Server]
wildcard characters [SQL Server]
characters [SQL Server], wildcard
TSQL
=azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric

Percent character (wildcard - character(s) to match) (Transact-SQL)

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance Fabricsqldb]

Matches any string of zero or more characters. This wildcard character can be used as a prefix, a suffix, or in the middle of the string. The pattern string can contain more than one % wildcard.

Examples

Example A: Match end of string

The following example returns the first and last names of people in the Person.Person table of [!INCLUDE sssampledbobject-md], where the first name starts with Dan.

SELECT FirstName, LastName
FROM Person.Person
WHERE FirstName LIKE 'Dan%';
GO

Example B: Match middle of string

The following example returns the first and last names of people in the Person.Person table of [!INCLUDE sssampledbobject-md], where the first name starts with J and ends with n.

SELECT FirstName, LastName
FROM Person.Person
WHERE FirstName LIKE 'J%n';
GO

See also