sql server怎么如此不健壯(郁悶)
我在存儲過程里作如下語句:
SELECT @statement = N '
SELECT S.ProNo, S.WareHouse, S.CurrentStock,S.UnitCost, S.StkPercent, StkAmt=isnull(CurrentStock, 0)*isnull(T.tda092f, 0),S.ProDep ,
S.ProName, ProName2=T.tda30c, Unit=tda08c, S.ProCtgr, S.ProType, Barcode=T.tda02c, WareHouseName= ' '總倉 ' ',
T.tda04c FXRQ,T.tda092f BZDJ,T.tda092f,T.tda102f
FROM #stock S, tdm01 T
WHERE T.tda00c = '+@company+ ' AND T.tda01c = S.ProNo '
+ @sortcondition
SELECT @statement=N '
SELECT t.*,ISNULL(XHSL,0) XHSL,ISNULL(XTSL,0) XTSL,SSSL=ISNULL(XHSL,0)-ISNULL(XTSL,0),XHCB=0,XHJE=0
FROM ( '+@statement+ ')t
left join (
select * from
(SELECT die03c,sum(die071f) XHSL FROM dim05 v
INNER JOIN dim04 t ON t.did01c=v.die01c
GROUP BY die03c)t
left join
(select dme03c,ISNULL(sum(dme071f),0) XTSL from dmm05 v
INNER JOIN dim04 t ON t.did01c=v.dme01c
GROUP BY dme03c)v
on t.die03c=v.dme03c)v on t.ProNo=v.die03c '
只要我稍微動一下語句有時就會出錯!是不是Sql Server書寫比較嚴格,還是什么原因。
問題搞了我一天了!我用的是C++Build4.0,老是報什么SQL ERROR.
[解决办法]
C++Build4.0
感觉上这个比SQL书写还要严格:)