SQL Server – Using LIKE for a Range of Numbers

sql serversql-server-2008t-sql

In my WHERE clause, I'm trying to use LIKE for a range of numbers. For example:

WHERE rr.sequence LIKE '05600%' 
   OR rr.sequence LIKE '05601%' 
   OR rr.sequence LIKE '05602%' 
OR rr.sequence BETWEEN LIKE('056035%' AND '056038%')

Otherwise, I would need to use a LIKE statement for each potential number combination between '056035%' and '056038%'

Best Answer

It looks like you need to do the following:

OR rr.sequence LIKE '05603[5-8]%'

But in general, I agree with Kin's comment on the question: "storing numbers as strings is not a good idea".