Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select SUM Problem

Author  Topic 

joelseverich
Starting Member

34 Posts

Posted - 2010-10-08 : 10:30:31
Hi there,
I tried to excecute this code
UPDATE TableA
SET Last =
(SELECT SUM(Cost) AS Expr1
FROM Trans
WHERE (Code = TableA.Code) AND (Estate = 0) AND (Tran = 'D0001') AND ([D/H] = 'D') AND (MONTH(CurDate) = 1))
WHERE (Code LIKE '1%');

But a Message says not nulls allowed, please help me

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-08 : 10:46:59
Your subselect is returning null values for one or some or all rows.
Check your subselect if this is true and ok.
The column Last isn't accepting null values.
How do want to handle that?
Insert 0 instead of null?
Alter table to allow null values?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -