Multiple wildcards in Like operator of SQL

Rajnilari2015
Posted by Rajnilari2015 under Sql Server category on | Points: 40 | Views : 290
Let's say we have a table as under

Record  
Othelo
Macbeth
IPL
Performance Tuning


The expected output should be

Record  
Othelo
Macbeth


Query
------


DECLARE @t TABLE (Record VARCHAR(500))
INSERT INTO @t
SELECT 'Othelo' UNION ALL
SELECT 'Macbeth' UNION ALL
SELECT 'IPL' UNION ALL
SELECT 'Performance Tuning'



SELECT * 
FROM @t
WHERE Record LIKE '%[H,B]%'


So here we have used Multiple wildcards in LIKE operator to accomplish the result.

Comments or Responses

Login to post response