Flysir


学习与工作就是:如果你报着一直在玩的态度,也许会做得更好哟 ^.^

导航

流水号生成(格式:YYYYMMDD+6位流水号)

------------------------------------------------
-- 插入用户买点数信息
------------------------------------------------
CREATE PROCEDURE InsertUserAccount
    @Phone        NVARCHAR(15),
    @Point          int,
    @Status            NVARCHAR(50),
    @Step1Time     DATETIME  ,
    @PayBy       NVARCHAR(100),
    @ID           INT = 0 OUTPUT
AS
    SET NOCOUNT ON

-----------------------------------------生成流水号作为单据号--------------------------------
declare @ordid nvarchar(100)
declare @ord nvarchar(100)
declare @time nvarchar(100)

select @ord=isnull(max(right(orderNO,6)),'000000') from UserAccount  where left(orderNO,8)=CONVERT(varchar,getdate(),112)
set @ord=cast((cast(@ord as bigint)+1) as varchar)
if(len(@ord)<6)
begin
 SET @ord = '000000' + @ord
 SET @ord = substring(@ord, len(@ord) - 5, 6)
end

set @time=CONVERT(varchar,getdate(),112)

set @ordid=@time+@ord
-------------------------------------------流水号生成完毕----------------------------------------

    INSERT [UserAccount]
 (
          orderNO, 
          phone,
                      point,
         status,
                     Step1Time,
                     PayBy
 )

    SELECT
         @ordid, 
        @Phone,
           @Point,
           @Status,
 @Step1Time,
 @PayBy

select @ordid

------------------------------------------------
GO

posted on 2006-02-08 16:00  Flysir  阅读(1903)  评论(0编辑  收藏  举报