create proc test(@InDepot int,@Depot int)
as 
select convert(varchar(20),@InDepot)+convert(varchar(10),getdate(),102)+convert(varchar(20),@Depot)

解决方案 »

  1.   

    CREATE PROCEDURE CreateSN
    @InDepotID int,
    @DepotID int,
    @RetValue varchar(长度) output
    AS
           select @RetValue= convert(varchar,@InDepot)+convert(varchar,year(getdate()))+convert(varchar,month(getdate()))+convert(varchar,day(getdate()))+convert(varchar,@Depot)
    GO
      

  2.   

    调用:
    declare @RetValue varchar
    CreateSN 1,2,@RetValue
    select @RetValue
      

  3.   

    create proc GetStringSN (@PDepotid int,@result varchar(100) output )
    as
    Begin
     select @result=convert(char(4),InDepotId)+convert(datetime ,getdate(),112)+convert(char(4),DepotId)
     from InDepot
    where @PDepotid=InDepotID
     
    End
      

  4.   

    一句sql能写的出来还用存储过程??
    select (InDepotSN+':'+cast(InDepotID as varchar(20))+convert(char(10),getdate(),20)+cast(DepotID as varchar(20)) as indeport from indeport