[阅读: 530] 2004-09-29 07:27:31
create function fn_LeftASC(@str varchar(4000))
returns int
as
begin
declare @i int,@itmp int,@iReturn int
select @i=1
select @iReturn=0
while @i<=len(@str)
begin
-- select @itmp=convert(int,substring(convert(varbinary,substring(@str ,@i,1)),1,1))
-- if @itmp>127
select @itmp=unicode(substring(@str ,@i,1))
if @itmp>19967 --\u4e00 - 1
begin
select @iReturn=@i-1
break
end
select @i=@i+1
end
return @iReturn
end
--select dbo.fn_LeftASC('PRM065腳釘')
耗费我不短时间,请我客不?