Home > Database > Mysql Tutorial > body text

sqlserver中求字符串中汉字的个数的sql语句

WBOY
Release: 2016-06-07 18:05:42
Original
1634 people have browsed it

sqlserver中求字符串中汉字的个数的sql语句,需要的朋友可以参考下

关于这个话题,我也看到网上有其他方法来解决。
不过从性能和代码量上来看,我有更好的办法。
在这里和大家 分享。
原理其实很简单,
知识1、长度函数 len();
知识2、还是长度函数datalength();

代码如下:
代码如下:
declare @sql varchar(1000)
set @sql='abc国m,de中d国e人民f'
select @sql 字符,DATALENGTH(@sql)-len(@sql) 汉字个数
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!