I've got the following query:
SELECT *
FROM sys.objects AS O
WHERE O.is_ms_shipped = 0
AND O.name LIKE '%[A-Z][A-Z][A-Z]%' COLLATE Latin1_General_CS_AS;
This is supposed to find all objects within the database that have at least three consecutive capital characters, however it doesn't seem to work and I'm not really sure why. I've tried to list all characters explicitly instead of specifying range, but it didn't solve the problem.
Sample data:
name
---------
HTMLTable
HtmlTable
Desired output:
name
---------
HTMLTable
The below code should work -
SELECT name
FROM sys.objects AS O
WHERE O.is_ms_shipped = 0
AND O.name LIKE '%[ABCDEFGHIJKLMNOPQRSTUVWXYZ][ABCDEFGHIJKLMNOPQRSTUVWXYZ][ABCDEFGHIJKLMNOPQRSTUVWXYZ]%' COLLATE Latin1_General_CS_AS;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With