I would like repeat LIKE pattern 7 times in my queries.
SELECT count(displayName),
AS nbDisplayNameDefaut
FROM users
WHERE displayName LIKE 'user[0123456789]'
This query return all display name like userX but i would like to have seven time numbers to have display name like this userXXXXXXX (X is numbers)
I think that this query is not optimized if I make this :
LIKE 'user[0123456789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789]'
I don't find the option in SQL-Server doc
SQL Server LIKE supports range patterns so you can use [0-9]
instead of [01234567899]
for a single decimal digit. This pattern can be replicated for the number of digits desired for a more concise expression:
LIKE 'user' + REPLICATE('[0-9]', 7)
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