F
F
Fyodor2015-03-18 10:22:44
SQL Server
Fyodor, 2015-03-18 10:22:44

How to search by phone number in MSSQL if it is not normalized?

There is a system that was not developed by us, in which customer numbers are entered in the MSSQL database in the form

+7-913-921-58-11
89039578611
8(983)309 64 11
89139435511, 89134775711

those. this field is just of type nvarchar(128)
is there any way to search by number of type LIKE? Well, there, let's say, when comparing, do not take into account anything in the line except numbers? Phones get into the database from a program for windows where the phone is entered simply as a string, there, respectively, nothing can be done with them =(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Panov, 2015-03-18
@Richard_Ferlow

Good afternoon. Try to get a field in which you will add only the numbers from the source string (do preprocessing with a trigger for an insert, for example).
As a result, you will get a field by which it will be easy to search.

S
Sergey, 2015-03-19
@smart_ex

How about using RLIKE (REGEXP) ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question