1

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?

qxg
  • 6,955
  • 1
  • 28
  • 36
HugMyster
  • 329
  • 1
  • 4
  • 14
  • If it's TSQL, it's a dup http://stackoverflow.com/questions/439495/how-can-i-escape-square-brackets-in-a-like-clause – qxg Sep 30 '16 at 15:22
  • use `ESCAPE` https://msdn.microsoft.com/en-us/library/ms179859.aspx – Horaciux Sep 30 '16 at 15:48

1 Answers1

1
where   @test not like '%[+=!*%(){}^-]%'
  • 1
    Now that makes sense! Put the '-' at the end so it isn't a range and the '^' so it isn't at the beginning. Actually perfectly sensible - thank you. – HugMyster Sep 30 '16 at 15:57