如何分隔一列中的电话号码和单元号? [英] How do you separate phone number and cellnumber that are in one column?

查看:65
本文介绍了如何分隔一列中的电话号码和单元号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

细胞编号和电话号码在一列中,它们的格式不同,例如(021-5454456,0213434559,021 3469564),细胞编号为此格式(0784595984,078 7894836)。我想只显示单元格编号。

Cell numbers and Phone numbers are in one column and they are in different format eg(021-5454456,0213434559, 021 3469564) and cell numbers are in this format(0784595984,078 7894836). I want to display only cell numbers.

推荐答案

Regulat表达式可能对你有帮助。

不幸的是(其中包括)regexp不是内置的在sql server中,你可以拥有它:

xp_pcre - T-SQL中的正则表达式 [ ^ ]

MS SQL Server 2005/2008中的正则表达式 [ ^ ]



您还需要拆分该字段中与之匹配的值手机模式,无论那是什么。这也可以这样做: http://ole.michelsen.dk/ blog / split-string-to-table-using-transact-sql.html [ ^ ]



仍然看起来更好的创建正确的CLR功能 [ ^ ]执行拆分和过滤,它只返回所需的值作为表(甚至格式相同) - 或移动如上所述,这个功能位于上层。
Regulat expression s might help you.
Unfortunatelly (among others) regexp is not built in in sql server, but you can have it:
xp_pcre - Regular Expressions in T-SQL[^]
Regular Expressions in MS SQL Server 2005/2008[^]

You will also need to split the values in that field that match with the cell phone pattern, whatever that would be. This can be also done: http://ole.michelsen.dk/blog/split-string-to-table-using-transact-sql.html[^]

Still it looks better to either create a proper CLR function[^] that does the splitting and the filtering and it is returning only the desired values as table (even formatted identically) - or to move this functionality in an upper layes, as SA suggested.


它只是意味着您选择了极其糟糕的数据库模式。您应该将它们组织为单独的记录,而不是将这些字符串分开。例如,您可以有一个电话号码表,其中字段显示其类型(移动电话,家庭电话等),或者(更糟)具有固定数量的电话作为个人或组织的属性。类似的东西。



-SA
It simply means that you have chosen extremely bad database schema. Instead of separating these strings, you should have organized storage of them as separate records. For example, you could have a table of phone numbers with the field showing its type (mobile, home, etc.), or (worse) have fixed number of phones as attributes of the person or organization. Something like that.

—SA


非常感谢我这样使用:select *来自tblName,其中col不喜欢'021%'
Thank you so much i used like this: select * from tblName where col not like '021%'


这篇关于如何分隔一列中的电话号码和单元号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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