在 SQL Server 2000 中验证电话号码 [英] Validate telephone number in SQL Server 2000

查看:63
本文介绍了在 SQL Server 2000 中验证电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有使用 sql (SQL Server 2000) 验证电话号码的绝妙方法.

Does anyone have a nifty way of validating telephone numbers using sql (SQL Server 2000).

我需要从 ma Db 中选择所有拥有有效电话号码的用户

I need to select all users fro ma Db that have valid phone number

谢谢喷

Valid number 
08450000000
01332000000
07444000000
+441332000000

标准英国号码

推荐答案

如果您有一个正则表达式来匹配数字,您可以在您的 SQL Server 上安装一个正则表达式扩展存储过程.我在工作中安装了这个扩展存储过程,我们经常使用它.有几个过程(每个过程都有相应的函数包装器):

If you have a regular expression to match the number, you can install a regex extended stored procedure on your SQL Server. I installed this extended stored procedure at work and we use it quite a bit. There are several procedures (each with corresponding function wrappers):

  1. 检查匹配(是,否)
  2. 检查匹配(计数)
  3. 搜索和替换
  4. 格式
  5. 拆分

要查找匹配项,您可以这样使用它:

To find matches you would use it as such:

 select number 
 from numberTable
 where dbo.fn_pcre_match(number, 'someRegex') = 1

其中 'someRegex' 是与您要查找的格式匹配的正则表达式.这个网站有一些匹配,但我没有确定它们的工作情况如何,因为我根本不熟悉英国的号码.

Where 'someRegex' is the regular expression matching the format you are looking for. This site has some matches on it, but I'm not sure how well they work since I'm not familiar with UK numbers whatsoever.

这篇关于在 SQL Server 2000 中验证电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆