在第一步中,我正在创建表的结构,第二步我正在将一个表中的数据插入到第一个表中,第三步我正在将另一个表中的数据插入到第一个表中,第四步我正在显示 d 插入的数据。但是这个程序不起作用。你能告诉我我哪里错了吗
CREATE PROCEDURE [dbo].[ISP_ANNEXURE_10]
@SDATE SMALLDATETIME,@EDATE SMALLDATETIME,
@SAC AS VARCHAR(60),@EAC AS VARCHAR(60)
,@SIT AS VARCHAR(100),@EIT AS VARCHAR(100)
AS
BEGIN
SELECT PEMAIN.TRAN_CD,PEMAIN.TRAN_DT,PEMAIN.TRAN_NO,
PEMAIN.BILL_NO,PEMAIN.BILL_DT, PEMAIN.[RULE],
CM_MAST.AC_NM,PEMAIN.CONS_NM,PEMAIN.NET_AMT,PEITEM.QTY,
PEITEM.RATE,PEMAIN.GRO_AMT, PEITEM.ASSES_AMT,PEITEM.EXAMTPER,PEITEM.EXAMT,PEITEM.CESSPER,PEITEM.CESS_AMT, PEMAIN.SHCESSPER,PEITEM.SHCESS_AMT,PEITEM.PROD_NM,CM_MAST.ECC_NO,CM_MAST.VEND_NM,
PT_MAST.CHAP_NM
INTO #ANNXR10
FROM PEMAIN INNER JOIN PEITEM ON (PEMAIN.TRAN_CD=PEITEM.TRAN_CD AND PEMAIN.TRAN_ID=PEITEM.TRAN_ID)
INNER JOIN PT_MAST ON (PEITEM.PROD_CD=PT_MAST.PROD_CD)
INNER JOIN CM_MAST ON (PEMAIN.AC_ID=CM_MAST.AC_ID)
WHERE 1=2
INSERT INTO #ANNXR10 SELECT PEMAIN.TRAN_CD,PEMAIN.TRAN_DT,PEMAIN.TRAN_NO, PEMAIN.BILL_NO,PEMAIN.BILL_DT,PEMAIN.[RULE],
CM_MAST.AC_NM,PEMAIN.CONS_NM,PEMAIN.NET_AMT,PEITEM.QTY,PEITEM.RATE,PEMAIN.GRO_AMT,
PEITEM.ASSES_AMT,PEITEM.EXAMTPER,PEITEM.EXAMT,PEITEM.CESSPER,PEITEM.CESS_AMT,
PEMAIN.SHCESSPER,PEITEM.SHCESS_AMT,PEITEM.PROD_NM,CM_MAST.ECC_NO,CM_MAST.VEND_NM,PT_MAST.CHAP_NM
FROM PEMAIN INNER JOIN PEITEM ON (PEMAIN.TRAN_CD=PEITEM.TRAN_CD AND PEMAIN.TRAN_ID=PEITEM.TRAN_ID)
INNER JOIN PT_MAST ON (PEITEM.PROD_CD=PT_MAST.PROD_CD)
INNER JOIN CM_MAST ON (PEMAIN.AC_ID=CM_MAST.AC_ID)
INSERT INTO #ANNXR10 SELECT SRMAIN.TRAN_CD,SRMAIN.TRAN_DT,SRMAIN.TRAN_NO,'','',SRMAIN.[RULE],
CM_MAST.AC_NM,SRMAIN.CONS_NM,SRMAIN.NET_AMT,SRITEM.QTY,SRITEM.RATE,SRMAIN.GRO_AMT,
SRITEM.ASSES_AMT,SRITEM.EXAMTPER,SRITEM.EXAMT,SRITEM.CESSPER,SRITEM.CESS_AMT,
SRMAIN.SHCESSPER,SRITEM.SHCESS_AMT,SRITEM.PROD_NM,CM_MAST.ECC_NO,CM_MAST.VEND_NM,PT_MAST.CHAP_NM
FROM SRMAIN INNER JOIN SRITEM ON (SRMAIN.TRAN_CD=SRITEM.TRAN_CD AND SRMAIN.TRAN_ID=SRITEM.TRAN_ID)
INNER JOIN PT_MAST ON (SRITEM.PROD_CD=PT_MAST.PROD_CD)
INNER JOIN CM_MAST ON (SRMAIN.AC_ID=CM_MAST.AC_ID)
SELECT A10.TRAN_CD,A10.TRAN_DT,A10.TRAN_NO, A10.BILL_NO,A10.BILL_DT, A10.[RULE],
A10.AC_NM,A10.CONS_NM,A10.NET_AMT,A10.QTY,A10.RATE,A10.GRO_AMT,
A10.ASSES_AMT,A10.EXAMTPER,A10.EXAMT,A10.CESSPER,A10.CESS_AMT,
A10.SHCESSPER,A10.SHCESS_AMT,A10.PROD_NM,A10.ECC_NO,A10.VEND_NM,A10.CHAP_NM
FROM #ANNXR10 A10
WHERE A10.TRAN_CD IN('PE','SR') AND A10.[RULE]='EXCISABLE'
AND A10.TRAN_DT BETWEEN @SDATE AND @EDATE
AND A10.AC_NM BETWEEN @SAC AND @EAC
AND A10.PROD_NM BETWEEN @SIT AND @EIT
DROP TABLE #ANNXR10
END