位置: 编程技术 - 正文

sqlserver 中charindex/patindex/like 的比较

编辑:rootadmin
一、测试环境: 1。数据库:Sql Server 2。测试表:记录,char类型主键,无其他索引 3。测试字段:ntext 类型,最大数据长度 二、测试语句: 1。select * from ProductTemp where ProductDesc like '%...%' 2。select * from ProductTemp where charindex('...',ProductDesc)>0 3。select * from ProductTemp where patindex('%...%',ProductDesc)>0 三、测试结果: 1。效率测试结果: charindex > like > patindex ,效率差大概% 2。适用性测试结果: 1)charindex对于检索结果最大位移有要求,经测试,Sql中的ntext字段,位移不能超过,否则返回0; 2)patindex 和 like 无位移限制; 3)patindex 支持匹配表达式,可以应用正则; 4)like可以用'%oldstring%'进行模糊匹配; 5)charindex只能匹配固定字符串

推荐整理分享sqlserver 中charindex/patindex/like 的比较,希望有所帮助,仅作参考,欢迎阅读内容。

sqlserver 中charindex/patindex/like 的比较

文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!

SQL 大数据量检索的分页 @StartIndex为当前页起始序号,@EndIndex为当前页结束记录序号,可以直接作为参数输入,也可以通过输入PageSize和PageIndex计算得出select*from(select*,row_number()ov

MSSQL INSERT,UPDATE,DELETE 之OUTPUT子句使用实例 --Title:Generatingtestdata--Author:wufeng--Date:--::ifobject_id('ta')isnotnulldroptabletagocreatetableta(IDintidentity,[name]varchar())insertta([name])select'a'unionallselect'b'uni

MSSQL 字符段分段更新 --分段更新--Author:wufeng--Date:--::--如:更新'a,a,a,a,a'第三段a?'test'?果??a,a,a,test,a'declare@svarchar()--更新的字符串declare@splitvarchar()--分割符declare@

本文链接地址:https://www.jiuchutong.com/biancheng/319285.html 转载请保留说明!

上一篇:SQLServer 数据集合的交、并、差集运算(sqlserver 数据集字符集种类)

下一篇:SQL2005 大数据量检索的分页(大数据sql教程)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络