开发者

How to find if a word has all vowels (SQL Server 2005)

开发者 https://www.devze.com 2022-12-15 22:30 出处:网络
DECLARE @开发者_运维技巧t TABLE(Words VARCHAR(100)) INSERT INTO @t SELECT \'Stack Overflow\' UNION ALL
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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号