Home > Database > Mysql Tutorial > SQL server自定义函数实例

SQL server自定义函数实例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:43:07
Original
998 people have browsed it

create function dbo.t_bh (@str varchar(20)) returns varchar(20) as begin declare @bh varchar(20),@length int,@i int set @length=12-LEN(@str) if LEN(@str)12 begin set @i=0 while @i@length begin set @str='0'+@str set @i=@i+1 end return @str

create function dbo.t_bh (@str varchar(20))

returns varchar(20)

as

begin

 declare @bh varchar(20),@length int,@i int

 set @length=12-LEN(@str)

  if LEN(@str)

   begin

   set @i=0

   while @i

    begin

     set @str='0'+@str

     set @i=@i+1

    end

    return @str

   end

   else if isnull(@str,0)=0

   begin

   set @str='000000000000'

   return @str

   end

   else

    begin

    return @str

    end

  return @str

end

 

--select dbo.t_bh('000022')

,美国空间,网站空间,美国服务器
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
server
From 1970-01-01 08:00:00
0
0
0
Configure server
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template