MSSQL 提取汉字实现语句
网络整理 - 08-24
-->Title:生成測試數據
-->Author:wufeng4552
-->Date :2009-09-21 09:02:08
if object_id('dbo.get_china_str')is not null drop function dbo.get_china_str
go
create function dbo.get_china_str
(
@str nvarchar(200)
)
returns nvarchar(200)
as
begin
declare @i int
set @i=1
while @i<=len(@str)
begin
if len(unicode(substring(@str,@i,1)))<5
begin
set @str=stuff(@str,@i,1,'');
end
else
set @i=@i+1;
end
return @str
end
go
select dbo.get_china_str(N'UNION ALL SELECT 我们都是中国人,都是炎黄子孙,都是龙人传人')