--参考:if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fun_getbh]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[fun_getbh]
GO/*--得到汉字笔画 得到指定汉字的笔画数
引自:http://expert.csdn.net/Expert/topic/3051/3051568.xml?temp=.221142--作者: J9988 --*/
create function fun_getbh(@char nchar(2))
returns int
as
begin
return(
case when unicode(@char) between 19968 and 40869 then(
select top 1 id from(
select id=1,ch=N'亅' union all select 2,N'阝'
union all select 3,N'马' union all select 4,N'风'
union all select 5,N'龙' union all select 6,N'齐'
union all select 7,N'龟' union all select 8,N'齿'
union all select 9,N'鸩' union all select 10,N'龀'
union all select 11,N'龛' union all select 12,N'龂'
union all select 13,N'龆' union all select 14,N'龈'
union all select 15,N'龊' union all select 16,N'龍'
union all select 17,N'龠' union all select 18,N'龎'
union all select 19,N'龐' union all select 20,N'龑'
union all select 21,N'龡' union all select 22,N'龢'
union all select 23,N'龝' union all select 24,N'齹'
union all select 25,N'龣' union all select 26,N'龥'
union all select 27,N'齈' union all select 28,N'龞'
union all select 29,N'麷' union all select 30,N'鸞'
union all select 31,N'麣' union all select 32,N'龖'
union all select 33,N'龗' union all select 35,N'齾'
union all select 36,N'齉' union all select 39,N'靐'
union all select 64,N'龘'
)a where ch>=@char collate Chinese_PRC_Stroke_CS_AS_KS_WS
order by id ASC) else 0 end)
end
go--函数调用实例:
select dbo.fun_getbh('华'),dbo.fun_getbh('華')
drop function [dbo].[fun_getbh]
GO/*--得到汉字笔画 得到指定汉字的笔画数
引自:http://expert.csdn.net/Expert/topic/3051/3051568.xml?temp=.221142--作者: J9988 --*/
create function fun_getbh(@char nchar(2))
returns int
as
begin
return(
case when unicode(@char) between 19968 and 40869 then(
select top 1 id from(
select id=1,ch=N'亅' union all select 2,N'阝'
union all select 3,N'马' union all select 4,N'风'
union all select 5,N'龙' union all select 6,N'齐'
union all select 7,N'龟' union all select 8,N'齿'
union all select 9,N'鸩' union all select 10,N'龀'
union all select 11,N'龛' union all select 12,N'龂'
union all select 13,N'龆' union all select 14,N'龈'
union all select 15,N'龊' union all select 16,N'龍'
union all select 17,N'龠' union all select 18,N'龎'
union all select 19,N'龐' union all select 20,N'龑'
union all select 21,N'龡' union all select 22,N'龢'
union all select 23,N'龝' union all select 24,N'齹'
union all select 25,N'龣' union all select 26,N'龥'
union all select 27,N'齈' union all select 28,N'龞'
union all select 29,N'麷' union all select 30,N'鸞'
union all select 31,N'麣' union all select 32,N'龖'
union all select 33,N'龗' union all select 35,N'齾'
union all select 36,N'齉' union all select 39,N'靐'
union all select 64,N'龘'
)a where ch>=@char collate Chinese_PRC_Stroke_CS_AS_KS_WS
order by id ASC) else 0 end)
end
go--函数调用实例:
select dbo.fun_getbh('华'),dbo.fun_getbh('華')
解决方案 »
- 为链接服务器的 OLE DB 访问接口 "SQLNCLI" 无法启动分布式事务
- 谁帮写个算法,取36进制字符串的下一个
- 如何将两张表中的数据汇总到一张表中?
- |zyciis| 求SQL 约束的教学视频 谢谢
- 求一条简单SQL语句
- 求教一段连表 update 的 SQL语句
- {"在 Range 对象中,Min (12)必须小于或等于 max (-1)。"}
- 在线求一SQL语句
- 如何获取包含“社区服务受理中心”数据的表以及列名字?
- 谁能用最通俗易懂的语言解释一下数据库的三个范式?
- 十万火急 我选择了MDF文件后 提示说CREAT FILE遇到操作系统错误32(另一个程序正在使用此文件,进程无法访问) 我把该关的都关了 不知道是什么在使用
- 这样的SQL语句应如何实现?
substring(cTitle,1,1) as a
from [contents]
where typeID=14
order by substring(cTitle,1,1) collate Chinese_PRC_Stroke_CS_AS_KS_WS
create table tb(name varchar(10))
insert into tb values('一')
insert into tb values('二')
insert into tb values('三')
insert into tb values('四')
insert into tb values('王')
insert into tb values('马')
goselect * from tb order by substring(name,1,1) collate Chinese_PRC_Stroke_CS_AS_KS_WS drop table tb/*
name
----------
一
二
三
马
王
四(所影响的行数为 6 行)*/