论坛里有一个:
http://topic.csdn.net/t/20051228/14/4486325.html
另外就是我自己也收集了一个:
create  function F_Convert(
@str nvarchar(4000), --要转换的字符串
@flag bit            --转换标志,0转换成半角,1转换成全角
)returns nvarchar(4000)
as
begin
declare @pat nvarchar(8),@step int,@i int,@spc int
if @flag=0
select @pat=N'%[!-~ ]%',@step=-65248
else
select @pat=N'%[!-~ ]%',@step=65248
set @i=patindex(@pat COLLATE Latin1_General_BIN,@str)
while @i>0
select @str=stuff(@str,@i,1,nchar(case unicode(substring(@str,@i,1))
when 32 then 12288
when 12288 then 32
else unicode(substring(@str,@i,1))+@step end))
,@i=patindex(@pat COLLATE Latin1_General_BIN,@str)
return(@str)
end
应该说我收集这个是比较简单的,只是难理解一点,不过核心问题在于 Unicode这个函数,mysql好像没有,意思好像也就是出得每个字符的编码,mysql不知道对应成啥,所以一直写不成功,请高手帮看下,谢谢