Obtain strokes of Chinese Characters

Source: Internet
Author: User

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

/* -- Obtain the strokes of Chinese Characters

-- Author: 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 'map' Union all select 4, N 'wind'
Union all select 5, N 'long' Union all select 6, N 'qy'
Union all select 7, n ''Union all Select 8, n 'tooth'
Union all select 9, N 'hangzhou' Union all select 10, N 'hangzhou'
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 'hangzhou' Union all select 16, N 'hangzhou'
Union all select 17, N 'hangzhou' Union all select 18, N 'hangzhou'
Union all select 19, N 'hangzhou' Union all select 20, N 'hangzhou'
Union all select 21, N 'hangzhou' Union all select 22, N 'hangzhou'
Union all select 23, N 'hangzhou' Union all select 24, N 'hangzhou'
Union all Select 25, N 'hangzhou' Union all select 26, N 'hangzhou'
Union all select 27, N 'hangzhou' Union all select 28, N 'hangzhou'
Union all select 29, N 'hangzhou' Union all select 30, N 'hangzhou'
Union all select 31, N 'hangzhou' Union all select 32, N 'hangzhou'
Union all select 33, N 'hangzhou' Union all select 35, N 'hangzhou'
Union all select 36, N 'hangzhou' Union all Select 39, N 'hangzhou'
Union all select 64, N 'hour'
) A where ch >=@ char collate chinese_prc_stroke_cs_as_ks_ws
Order by id asc) else 0 end)
End
Go

-- Function call instance:

Select DBO. fun_getbh ('hua'), DBO. fun_getbh ('shanghai ')
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.