I am currently trying to identify bad phone number in a database based on the exchange in relation to the area code.
Normally I will parse out the portion of the phone number -left(phone,7) and then do the comparision IN a list of the areacode+exchange.
However on occasion I am having to deal with some legacy information stored as text string in multiple field of a table. This limits using a direct lookup since I don't alway know where the number is going to be.
To resolve this I will concantenate the fields and search for the string using a like statement
line1+line2+line3+line4 like '%949[/-)]941-%'
In some case it will be a few hundred exchanges that are invalid in an area code, this means a few hundred lines.
Is there a cleaner way of doing this something along the lines of a IN statement within a LIKE statement?
Normally I will parse out the portion of the phone number -left(phone,7) and then do the comparision IN a list of the areacode+exchange.
However on occasion I am having to deal with some legacy information stored as text string in multiple field of a table. This limits using a direct lookup since I don't alway know where the number is going to be.
To resolve this I will concantenate the fields and search for the string using a like statement
line1+line2+line3+line4 like '%949[/-)]941-%'
In some case it will be a few hundred exchanges that are invalid in an area code, this means a few hundred lines.
Is there a cleaner way of doing this something along the lines of a IN statement within a LIKE statement?