Question : What's wrong with the below query?


Select DueDate, DeliveryDate,OrderNum
From Invnum Where OrderNum  in (select OrderNum from Items) and DocState in (1,3)
and OrderNum in
(
SELECT     isnull(SOno,'') FROM vuForInvNumTrig WHERE    (isnull(NoOfCntAllc,0) >                 isnull(Recd,0)) AND (POno = 'PO7943')
)

I am using the above query in a trigger its giving me an error like
'Null value is eliminated by an aggregate or other SET operation.'

When i execute the same query in a stored procedure window, it is returning results but with warning,

Warning: Null value is eliminated by an aggregate or other SET operation.
DueDate                 DeliveryDate            OrderNum            
----------------------- ----------------------- --------------------
8/30/2010               7/31/2010               SO4876              
No rows affected.
(1 row(s) returned)

Why this happens, please suggest a solution

Answer : What's wrong with the below query?

Try using the following query:

Select DueDate, DeliveryDate,OrderNum
From
      Invnum
Where OrderNum  in (select OrderNum from Items) and DocState in (1,3)
and OrderNum in (SELECT SOno FROM vuForInvNumTrig WHERE (isnull(NoOfCntAllc,0) > isnull(Recd,0)) AND (POno = 'PO7943') AND SOno IS NOT NULL)

If you simply want to supress the warning then set the following before script
SET ANSI_WARNINGS OFF

and reset at the end.
SET ANSI_WARNINGS ON
Random Solutions  
 
programming4us programming4us