Count words

0

Please login or register to vote for this query.

(click on this box to dismiss)

Count words

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @ varchar(max) = 'That''s... that''s... that is just terrible!" he said.';

WITH c as(SELECT
@ p,@ x
UNION ALL
SELECT LEFT(x,k-1),STUFF(x,1,k,'')FROM
c CROSS APPLY(SELECT patindex('%[^a-z''-]%',x+'!')k)k
WHERE''<x)SELECT max(p)FROM(SELECT top 1with ties p
FROM c WHERE p>''GROUP BY p
ORDER BY count(*)DESC
)j HAVING count(*)=1

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results