Skip to content

Latest commit

 

History

History
63 lines (52 loc) · 2.4 KB

File metadata and controls

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

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