CREATE PROCEDURE get_running_number
@id int,
@docNO varchar(20)  out
AS
begin
 declare @_id nvarchar(20)
 declare @i int
 set @_id = cast(@id as nvarchar)
 set @i = len(@_id)
 while (@i<5)
 begin
  set @_id = ‘0’ + @_id
  set @i = @i +1
 end
 set @_id = ‘WF0711’ + @_id
      select @docNO =  @_id
end
GO