我写了这样一个存储过程(SQL Server2000),
CREATE PROCEDURE [spZGPaySlip]-----------员工工序总产量表
(
@fdate datetime,
@ldate datetime,
@GoodsName varchar(20),
@Spec varchar(20),
@Mrr varchar(20),
@Jzr varchar(20),
@CardNo varchar(10),
@Type varchar(20)
)
AS
declare @UserID varchar(20),@TeamN varchar(20),@WPNo varchar(20),@WPName varchar(20),@WorkerName varchar(20),@WorkerNo varchar(20)
declare @AutoInc int,@CommandID int, @ModNum int,@OrderID int
declare @WPPrice money
--生成临时表#TMPTABLE
CREATE TABLE #TmpTable(
[AUTOINC] [int] IDENTITY (1, 1) NOT NULL ,
[BillTime] datetime null,
[GoodsName] [varchar] (30) null,
[Spec] [varchar] (20) null,
[CardNo] [varchar] (20) null,
[Mrr] [varchar](20) NULL ,
[SycpNum] [numeric](18,4) NULL ,
[SycmNum] [numeric](18,4) NULL ,
[MttrNum] [numeric](18,4) NULL ,
[MtsrNum] [numeric](18,4) NULL ,
[Jzr] [varchar] (20) null,
[InDepotTime] datetime null,
[InDepotNum] [numeric](18,4) NULL ,
[McNum] [numeric](18,4) NULL ,
[DzNum] [numeric](18,4) NULL ,
[FpNum] [numeric](18,4) NULL ,
[JrNum] [numeric](18,4) NULL ,
[RkceNum] [numeric](18,4) NULL ,
[CmNum] [numeric](18,4) NULL ,
[FcTime] datetime null,
[FcNum] [numeric](18,4) NULL ,
[CeNum] [numeric](18,4) NULL
) ON [PRIMARY]
insert into #TmpTable(BillTime,GoodsName,Spec,CardNo,Mrr,SycpNum,SycmNum ,MttrNum ,MtsrNum, Jzr, InDepotTime, InDepotNum, McNum,DzNum,FpNum,JrNum,RkceNum,CmNum,FcTime,FcNum,CeNum)
select hgrq,cpmc,gg,kh,xm,0,0,TLSL,HGZSkg,cjh,rkrq,rksl,mc,dz,fp,SCSYS,0,ZMSkg,hgrq,0,ysl
from ZDMMRJYLCK where HGRQ between @fDate and @lDate and CPMC like @GoodsName and GG like @Spec
and KH like @CardNo and MRLX like @Type
update #TmpTable set rkceNum=SycpNum+SycmNum+MtsrNum+CMNum-InDepotNum-CeNum-McNum-FpNum-DzNum+JrNum
select BillTime,GoodsName,Spec,CardNo,Mrr,SycpNum,SycmNum ,MttrNum ,MtsrNum, Jzr, InDepotTime, InDepotNum, McNum,DzNum,FpNum,JrNum,RkceNum,CmNum,FcTime,FcNum,CeNum
from #TmpTable
GO
弄了一个TStoredProcDatsSet指向它,在字段编辑器里新建数据字段时,可选字段为空,是不是要一个个自己加入?怎么弄?
|