SQL Filter numbers between x and x and ignore strings
SQL Filter numbers between x and x and ignore strings I have a table in SQL Server where I need to filter rooms by name and type. The problem is, that the names are stored as varchar and there are also some rooms with letters. I need to filter out the rooms with letters before I can compare them as int or otherwhise I will get an error. varchar int Here's an example from Room.Name: 030 210a 210b Lan-Room-A 240 I can work around the room names with a or b with LEFT(Rooms.Name, 3) but if I want to add (LEFT(Rooms.Name, 3) BETWEEN 0 and 350 and it gets to Lan-Room-A it oviously can't convert a string to int. I also need to do additional filtering like Room.Type = 6 for example. a b LEFT(Rooms.Name, 3) (LEFT(Rooms.Name, 3) BETWEEN 0 and 350 Lan-Room-A Room.Type = 6 SELECT Room.Name, Room.Descr, Room.MainUser WHERE LEFT(Room.Name, 1) NOT LIKE '%[0-9]%' AND LEFT(Room.Name, 3) BETWEEN 0 AND 350 AND Room.Type = 6 (Removed some joins for simplici...
