IF EXISTS(SELECT NAME FROM SYSOBJECTS WHERE NAME='出库_原因_PROC' AND TYPE='P')
DROP PROC 出库_原因_PROC
GO
create procedure 出库_原因_PROC
@res_to int,
@res_fr int
as
CREATE TABLE [#出库]
([物料编码] [varchar] (30),
[货位编码] [varchar] (10),
出库类型 CHAR(1),
[批号] [varchar] (15) ,
[原因码] [varchar] (10),
[处理日期] [datetime],
[单据号] [varchar] (20),
[仓库] [varchar] (10),
[出库数量] [numeric](18, 6) DEFAULT (0))
insert into #出库(物料编码,出库类型,出库数量,货位编码,批号,原因码,处理日期,单据号)
select 物料编码,出库类型,出库数量,货位编码,批号,原因码,处理日期,单据号 from 出库
where 原因码>=@res_to AND 原因码 SELECT* FROM #其他出库