SQL: Invalid Phone Fields: Locations

There are two versions of this SQL: Firebird and MySQL. The MySQL version only applies to clients who are have migrated to MySQL.. All other Practices should continue to use the Firebird version of this code. Click to expand and copy the code you need. If you are unsure which code to use, please check with your Practice Administrator.

About

This report shows phone numbers found in the Locations table that contain something other than 10 numeric values. After running this SQL, navigate to the Locations table to update the phone number(s): Practice Management tab > Practices/Locations > Locations tab > select Location.

A sample image of this SQL report run in the Database Viewer is shown below:

SQL Code: Firebird

To highlight and copy the code below to your clipboard, simply click the Copy button.

select  id ,loc_name ,loc_address_1 ,loc_address_2 ,loc_city ,loc_state ,loc_zip_code ,loc_phone
 from location where
(loc_phone not similar to  '[0-9]{3}[-]{0,1}[0-9]{3}[-]{0,1}[0-9]{4}[ ]{0,}' and loc_phone != '');


SQL Code: MySQL

To highlight and copy the code below to your clipboard, simply click the Copy button.

select  id ,loc_name ,loc_address_1 ,loc_address_2 ,loc_city ,loc_state ,loc_zip_code ,loc_phone
 from location where
(loc_phone not rlike  '^[0-9]{3}[-]{0,1}[0-9]{3}[-]{0,1}[0-9]{4}[ ]{0,}$' and loc_phone != '');