HugMyster HugMyster - 2 months ago 7
SQL Question

How can I use SQL's LIKE command with its own special characters?

I use Sybase Transact SQL with the very useful LIKE command, so to ensure that your string contains a number you simply need use:

WHERE @test LIKE "%[0-9]%"


Alternatively, to ensure that your list does not contain a number you can use:

WHERE @test LIKE "%[^0-9]%"


What test would I use to ensure that my string does not contain any of the basic mathematical functions (+, -, *, / and ^ for powers of) please? Is it a question of using square brackets in my square brackets?

Answer
where   @test not like '%[+=!*%(){}^-]%'
Comments