我在自定义部署包最后一步选择了自己编写的SQL脚本(新建存储过程),安装部署包提示成功,但数据库中没有新建存储过程,是怎么回事呢?是对SQL脚本有什么要求吗?
SQL脚本内容:
IF EXISTS(SELECT * FROM SYSOBJECTS WHERE NAME = 'P_Dev20161115_Report01')
DROP PROC P_Dev20161115_Report01
GO
create proc P_Dev20161115_Report01
@FReportID int,
@strWhereCondition1 nvarchar(max), --where 条件
@TableNameTemp nvarchar(max),
@strWhereCondition2 nvarchar(max)='' --where 条件
as begin
--P_Dev20161115_Report01 1,'','TMPEAF97D04B31811E680BB000C293',''
--P_Dev20161115_Report01 2,' where 1=1 ','Test0001',''
--select * from Test0001 drop table Test0001
if @FReportID=1
exec('SELECT identity(int,1,1) FIDENTITYID, FSupplier=t0_L.FName ,FCreator=st06.fname, FInvoiceCode= t1.F_PAEZ_FPBH
,FDate=max(convert(char(10),t0.FDATE,126) ) , FAmount= sum(convert(decimal(16,2),t1.FALLAMOUNTFOR)),F0=''''
into '+@TableNameTemp+'
FROM T_AP_PAYABLE t0 LEFT OUTER JOIN T_AP_PAYABLEENTRY t1 ON t0.FID = t1.FID
left join t_BD_Supplier_L t0_L ON t0.FSUPPLIERID = t0_L.FSUPPLIERID
left join t_BD_Supplier t0_S ON t0.FSUPPLIERID = t0_S.FSUPPLIERID
LEFT OUTER JOIN T_SEC_user st06 ON t0.FCREATORID = st06.FUserID '+
@strWhereCondition1 + ' group by t0_L.FName,t1.F_PAEZ_FPBH,st06.fname order by FSupplier,FDate')
else if (@FReportID=2 or @FReportID=3)
begin
--入库日期 供应商 物料名称 库存单位 实收数量 仓库 金额
exec('select identity(int,1,1) FIDENTITYID,FDate=convert(char(10),t0.FDATE,126),FSupplier=t0_L.FName,FMaterial=tm_L.fname,FUnit=tu_L.fname,
FQty=convert(decimal(16,0),t2.FREALQTY)
,FStock=ts_L.fname,FAmount=convert(decimal(16,2),T_STK_INSTOCKENTRY_F.FAMOUNT) into '+@TableNameTemp+' FROM t_STK_InStock t0
LEFT OUTER JOIN T_STK_INSTOCKENTRY t2 ON t0.FID = t2.FID
LEFT OUTER JOIN T_STK_INSTOCKENTRY_F ON t2.FEntryID = T_STK_INSTOCKENTRY_F.FEntryID
left join t_BD_Supplier t0_S ON t0.FSUPPLIERID = t0_S.FSUPPLIERID
left join t_BD_Supplier_L t0_L ON t0.FSUPPLIERID = t0_L.FSUPPLIERID
left join t_bd_unit_l tu_L ON tu_L.FUNITID = t2.funitid
left join T_BD_MATERIAL_L tm_L ON tm_L.FMATERIALID = t2.FMATERIALID
left join T_BD_STOCK ts ON ts.FSTOCKID = t2.FSTOCKID
left join T_BD_STOCK_L ts_L ON ts_L.FSTOCKID = t2.FSTOCKID
left join (select t1.FSOURCEBILLNO FROM T_AP_PAYABLE t0 LEFT OUTER JOIN T_AP_PAYABLEENTRY t1 ON t0.FID = t1.FID '+
@strWhereCondition1 + '
group by t1.FSOURCEBILLNO) tf on t0.FBILLNO=tf.FSOURCEBILLNO '+
@strWhereCondition2 + '
order by t0.fdate,t0_L.FName')
exec('insert into '+@TableNameTemp+' (FDate,FSupplier,FMaterial,FUnit,FQty,FStock,FAmount) select ''合计'','''','''','''',sum(FQty),'''',sum(FAmount) from '+@TableNameTemp)
end
end
Go
推荐阅读