Createfunctiondbo. t_bh (@ strvarchar (20) returnsvarchar (20) asbegindeclare @ bhvarchar (20), @ lengthint, @ iintset @ length12-LEN (@ str) ifLEN (@ str) 12beginset @ i0while @ I @ lengthbeginset @ str0 + @ strset @ I + 1endreturn @ 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) 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) <12
Begin
Set @ I = 0
While @ I <@ length
Begin
Set @ str = '0' + @ str
Set @ I = @ I + 1
End
Return @ str
End
Else if isnull (@ str, 0) = 0
Begin
Set @ str = '20140901'
Return @ str
End
Else
Begin
Return @ str
End
Return @ str
End
-- Select dbo. t_bh ('20140901 ')
, U.S. space, website space, U.S. servers