if exists(select 1 from sysobjects where name='f_get_str')
  drop function f_get_str
go

create function f_get_str(@amt decimal(16, 2) )
returns varchar(200) 
as
begin
	--¼ÓÃÜ×Ö·û´®
	declare 
	@ll_i int,
	@ll_len int,
	@ls_count varchar(200),
	@as_target varchar(200),
	@source varchar(200)

	set @source = convert(varchar(200),(@amt * 10000))

	select @source=reverse(@source)
	select @ll_len=len(@source),@ll_i=1,@ls_count=''

	while @ll_i<=@ll_len
	begin
		select @ls_count=@ls_count +char(ascii(substring(@source, @ll_i, 1))+(@ll_len - @ll_i - 2) * 2)
		select @ll_i= @ll_i +1
	end

	select @as_target = @ls_count
	return @as_target
end
go