How to find if a word has all vowels (SQL Server 2005)
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
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%'
... like %a% and like %e% .... is the only SQL way I know of. Is this homework?
Have you considered a CLR SQL Server function that uses a regular expression?
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.
精彩评论