USE [ShimadaWebOrder ]
GO
/****** Object: StoredProcedure [dbo].[sp_InsertOrderWovenLabel] Script Date: 04/23/2012 11:38:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_InsertOrderWovenLabel]
(
@ItemNo varchar(20),
@Color varchar(10),
@Size nvarchar(20),
@OrderQty int,
@RefNO varchar(20)output--输出参数编号
)
AS
BEGIN
DECLARE @NewRefNo CHAR(8)
DECLARE @MaxNo INT
SELECT @MaxNo=ISNULL(CONVERT(INT,RIGHT(MAX(RefNo),6)),0)+1 FROM O_OrderMaster ---MAX(RefNo)得到最大的依次增长
SELECT @NewRefNo='WL'+REPLICATE('0',6-LEN(@MaxNo))+CONVERT(VARCHAR,@MaxNo)
insert into O_OrderWovenLabel([RefNo],[ItemNo],[Color],[Size],[OrderQty])
values(@NewRefNo,@ItemNo,@Color,@Size,@OrderQty)
select @RefNO=RefNo from O_OrderWovenLabel where RefNo=@NewRefNo --输出参数
END