比對指定範圍内或者屬于方括号所指定的集合中的任意單個字元。可以在涉及模式比對的字元串比較(例如,LIKE 和 PATINDEX)中使用這些通配符。有關詳細資訊,請參閱搜尋條件中的模式比對。

示例
以下示例使用 [] 運算符查找其位址中有四位郵政編碼的所有 Adventure Works 雇員的 ID 和姓名。
複制代碼
USE AdventureWorks;
GO
SELECT e.EmployeeID, c.FirstName, c.LastName, a.PostalCode
FROM HumanResources.Employee AS e
INNER JOIN Person.Contact AS c ON e.ContactID = c.ContactID
INNER JOIN HumanResources.EmployeeAddress AS ea ON e.EmployeeID = ea.EmployeeID
INNER JOIN Person.Address AS a ON a.AddressID = ea.AddressID
WHERE a.PostalCode LIKE '[0-9][0-9][0-9][0-9]';
GO
下面是結果集:
複制代碼
EmployeeID FirstName LastName PostalCode
---------- ---------