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 ')