تحية طيبة
الجملة التالية أستخدمها فى إستخراج حركة الصنف باستخدام الوحدات المخزنية (وحدة كبرى أو صغرى بمعنى كارتونة أو قطعة) وقمت باستخدام هذه الجملة مسبقاً فى أكسس 2010 وكانت تعمل دون أى مشاكل ولكن تعطينى الأن مشكلة فى التنفيذ داخل Sql Server 2012... فما هو الخطأ فيها؟؟
SELECT Sum(IIf([actIn]='actIn',[calcQty],0))-Sum(IIf([actIn]='actOt',[calcQty],0)) AS iLastQty FROM (SELECT Sum(IIf([purUnitCount]=1 OR [purUnitCount]=0 OR [purUnitCount] Is Null,[purQty],([purUnitCount]*[purQty]))) AS calcQty, 'actIn' As actIn From tblPurchasesSub WHERE [purCodItemSub]=@cod UNION ALL SELECT Sum(IIf([reSalUnitCount]=1 OR [reSalUnitCount]=0 OR [reSalUnitCount] Is Null,[reSalQty],([reSalUnitCount]*[reSalQty]))) AS calcQty, 'actIn' As actIn From tblReSalesSub WHERE reSalCodItemSub=@cod UNION ALL SELECT Sum(IIf([repInUnitCount]=1 OR [repInUnitCount]=0 OR [repInUnitCount] Is Null,[repInQty],([repInUnitCount]*[repInQty]))) AS calcQty, 'actIn' As actIn From tblRepInSub WHERE repInCodItemSub=@cod UNION ALL SELECT Sum(IIf([trnInUnitCount]=1 OR [trnInUnitCount]=0 OR [trnInUnitCount] Is Null,[trnInQty],([trnInUnitCount]*[trnInQty]))) AS calcQty, 'actIn' As actIn From tblTransInSub WHERE trnInCodItemSub=@cod UNION ALL SELECT Sum(IIf([salUnitCount]=1 OR [salUnitCount]=0 OR [salUnitCount] Is Null,[salQty],([salUnitCount]*[salQty]))) AS calcQty, 'actOt' As actOt From tblSalesSub WHERE salCodItemSub=@cod UNION ALL SELECT Sum(IIf([rePurUnitCount]=1 OR [rePurUnitCount]=0 OR [rePurUnitCount] Is Null,[rePurQty],([rePurUnitCount]*[rePurQty]))) AS calcQty, 'actOt' As actOt From tblRePurchasesSub WHERE rePurCodItemSub=@cod UNION ALL SELECT Sum(IIf([repOtUnitCount]=1 OR [repOtUnitCount]=0 OR [repOtUnitCount] Is Null,[repOtQty],([repOtUnitCount]*[repOtQty]))) AS calcQty, 'actOt' As actOt From tblRepOutSub WHERE repOtCodItemSub=@cod UNION ALL SELECT Sum(IIf([trnOtUnitCount]=1 OR [trnOtUnitCount]=0 OR [trnOtUnitCount] Is Null,[trnOtQty],([trnOtUnitCount]*[trnOtQty]))) AS calcQty, 'actOt' As actOt From tblTransOutSub WHERE trnOtCodItemSub=@cod);
والخطأ كالتالى:
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '='.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '='.
Msg 102, Level 15, State 1, Line 6
Incorrect syntax near '='.
Msg 102, Level 15, State 1, Line 9
Incorrect syntax near '='.
Msg 102, Level 15, State 1, Line 12
Incorrect syntax near '='.
Msg 102, Level 15, State 1, Line 15
Incorrect syntax near '='.
Msg 102, Level 15, State 1, Line 18
Incorrect syntax near '='.
Msg 102, Level 15, State 1, Line 21
Incorrect syntax near '='.
Msg 102, Level 15, State 1, Line 24
Incorrect syntax near '='.
رجاءً الإفادة للأهمية
وشكراً
