views:

46

answers:

4
DECLARE @t TABLE(Words VARCHAR(100))
INSERT INTO @t 
    SELECT 'Stack Overflow' UNION ALL
    SELECT 'EQUATORIAL'

SELECT * FROM @t 
WHERE Words  LIKE '%[AEIOU]%'

I am getting both as the output

Words

Stack Overflow
EQUATORIAL

The desired output being EQUATORIAL

Thanks

A: 

Have you considered a CLR SQL Server function that uses a regular expression?

Andrew Hare
+1  A: 

... like %a% and like %e% .... is the only SQL way I know of. Is this homework?

No Refunds No Returns
+1 for being first with the answer.
Mark Wilkins
+1  A: 

I suppose the simplest version would be:

SELECT *
FROM @t 
WHERE Words LIKE '%A%'
AND Words LIKE '%E%'
AND Words LIKE '%I%'
AND Words LIKE '%O%'
AND Words LIKE '%U%'
Aaronaught
A: 

It is because like %[AEIOU]% is true if the word contains any one of them not all of them see Aaronaught or No Refunds for solution.

fupsduck