如何在sql server中使用正则表达式? [英] How to use Regular Expression in sql server?

查看:34
本文介绍了如何在sql server中使用正则表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用正则表达式功能集进行高效查询.我的表中的数据格式不正确,例如:-在标题栏:Cable 180â"¬â–' To 90â"¬â–' Serial ATA Cable 和 Id 列123234+ 中指数格式的数据,可以在 Sqlserver2008 中使用正则表达式进行查询.

Is it possible to make efficient queries that use regular expression feature set.I got data in my table which is not in correct format,EX:-In Title colum: Cable 180â"¬â–‘ To 90â"¬â–‘ Serial ATA Cable and in Id column 123234+ data in exponential format,it is possible to make queries using regular expression in Sqlserver2008.

推荐答案

您需要利用以下内容.通常需要三者的组合:

You need to make use of the following. Usually requires combinations of the three:

  1. patindex
  2. charindex
  3. 子串

针对您上面的评论,patindex 在找到案例的地方不应为 0.patindex 找到指定模式的起始位置,所以如果 patindex 找到大小写,它应该返回一个 > 0 的整数.

In response to your comment above, patindex should not 0 where the case is found. patindex finds the start location of the pattern specified, so if patindex finds the case, it should return an integer > 0.

此外,len(string)reverse(string) 在特定场合会派上用场.

Also, len(string) and reverse(string) come in handy on specific occasions.

这篇关于如何在sql server中使用正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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