日期:2014-05-18 浏览次数:20723 次
CREATE PROCEDURE cypQgoodsBuyD --按货品代号列出这个货品的采购详细记录 @goodsid VARCHAR(1000) AS SELECT CVS.code, b.BILLDATE, a.QTY,A.PRICES, d.[NAME],C.VENDORNO, C.SHORTNAME, C.CONTACTOR,C.PHONE,C.MOBILEPHONE, C.FAX FROM (SELECT GOODSID, QTY,cast(PRICE as decimal(10,3)) PRICES,BILLID FROM P_BILLD WHERE GOODSID in(@goodsid)) AS A LEFT JOIN P_BILL as B ON b.BILLID=a.BILLID LEFT JOIN VENDOR AS c ON c.VENDORID=b.VENDORID LEFT JOIN TERM AS d ON d.TERMID=b.TERMID LEFT JOIN cyVgoodsShort AS cvs ON CVS.GOODSID=A.GOODSID
SELECT CVS.code, b.BILLDATE, a.QTY,A.PRICES, d.[NAME],C.VENDORNO, C.SHORTNAME, C.CONTACTOR,C.PHONE,C.MOBILEPHONE, C.FAX FR[code=SQL]
动态执行 exec( 'SELECT CVS.code, b.BILLDATE, a.QTY,A.PRICES, d.[NAME],C.VENDORNO, C.SHORTNAME, C.CONTACTOR,C.PHONE,C.MOBILEPHONE, C.FAX FR OM (SELECT GOODSID, QTY,cast(PRICE as decimal(10,3)) PRICES,BILLID FROM P_BILLD WHERE GOODSID in('+@goodsid+')) AS A LEFT JOIN P_BILL as B ON b.BILLID=a.BILLID LEFT JOIN VENDOR AS c ON c.VENDORID=b.VENDORID LEFT JOIN TERM AS d ON d.TERMID=b.TERMID LEFT JOIN cyVgoodsShort AS cvs ON CVS.GOODSID=A.GOODSID')