怎么把2010-2012写一个标量值函数转换成二0一0——二一0二,这样格式,等急用,输入参数是nvarchar
输出参数也是nvarchar
------解决方案--------------------
- SQL code
create function f1(@s1 varchar(100))returns varchar(100)begin declare @c varchar(10)declare @s2 varchar(100)set @s2=''while len(@s1)>0begin set @c=left(@s1,1) set @[email protected]+case @c when '1' then '一' when '2' then '二' when '3' then '三' when '4' then '四' when '5' then '五' when '6' then '六' when '7' then '七' when '8' then '八' when '9' then '九' when '0' then '0' else '-' end set @s1=stuff(@s1,1,1,'')end return @s2end调用 declare @s3 varchar(100)select @s3=dbo.f1('2010-2012')select @s3结果 二0一0-二0一二