Home  >  Article  >  Database  >  sqlserver中求字符串中汉字的个数的sql语句

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

WBOY
WBOYOriginal
2016-06-07 18:05:421635browse

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

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

代码如下:
代码如下:
declare @sql varchar(1000)
set @sql='abc国m,de中d国e人民f'
select @sql 字符,DATALENGTH(@sql)-len(@sql) 汉字个数
Statement:
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