Solved

SQL Server Update Statement error:   Warning: Null value is eliminated by an aggregate or other SET operation.

Posted on 2011-03-08
5
563 Views
Last Modified: 2012-05-11
When I run this I get the error: Warning: Null value is eliminated by an aggregate or other SET operation.

I thought the isnull function would remove the error but it's not.  The query is actually running but I don't want the warning.  How can I handle this?

update hb
set PROGRAM_END_DATE = isnull(
(SELECT max(ef.END_DT) FROM AP_FACT..EN_FACT ef
where hb.program_assignment_id = ef.src_program_assignment_id
and ef.dim_program_id = 194 and
ef.END_DT < '2099-12-31 00:00:00.000'),'2099-12-31 00:00:00.000')
FROM #hbinterval hb

Thanks as always for your help,
Julia
0
Comment
Question by:rsmuckles
  • 2
  • 2
5 Comments
 
LVL 26

Expert Comment

by:tigin44
ID: 35074497
this message is not an error .. its a warning about the eliminated records while aplying aggregation faunction...
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 35074558
agree its only a warning...

would this suffice?

(or add a where clause into the sub-query and ignore null date values...)
update hb
set PROGRAM_END_DATE = 
(SELECT max(coalesce(ef.END_DT,'2099-12-31 00:00:00.000'))
   FROM AP_FACT..EN_FACT ef
where hb.program_assignment_id = ef.src_program_assignment_id 
and ef.dim_program_id = 194 
and ef.END_DT < '2099-12-31 00:00:00.000')
FROM #hbinterval hb

Open in new window

0
 
LVL 26

Expert Comment

by:tigin44
ID: 35074565
this should work withoot warning


update hb
set PROGRAM_END_DATE = isnull(
(SELECT max(ISNULL(ef.END_DT, '01.01.1900')) FROM AP_FACT..EN_FACT ef
where hb.program_assignment_id = ef.src_program_assignment_id
and ef.dim_program_id = 194 and
ef.END_DT < '2099-12-31 00:00:00.000'),'2099-12-31 00:00:00.000')
FROM #hbinterval hb
0
 

Author Comment

by:rsmuckles
ID: 35074567
I get that.  I should have used the word warning instead of error but is there a way to have this warning not appear?

It's a warning that there are some null ef.end_dt values and that those can't be 'maxed' right?  I thought I'd be handling the warning by using the isnull function which creates a dummy date in the case where there are null values.  Is there a way that I can run this that the warning won't happen?

update hb
set PROGRAM_END_DATE = isnull(
(SELECT max(ef.END_DT) FROM AP_FACT..EN_FACT ef
where hb.program_assignment_id = ef.src_program_assignment_id
and ef.dim_program_id = 194 and
ef.END_DT < '2099-12-31 00:00:00.000'),'2099-12-31 00:00:00.000')
FROM #hbinterval hb

0
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 500 total points
ID: 35074650
update hb
set PROGRAM_END_DATE = isnull(
(SELECT max(ef.END_DT) FROM AP_FACT..EN_FACT ef
where hb.program_assignment_id = ef.src_program_assignment_id
and ef.dim_program_id = 194 and
ef.END_DT < '2099-12-31 00:00:00.000')
,'2099-12-31 00:00:00.000')
FROM #hbinterval hb


the highlight component is/are what generates the Warning you need to address that part of the command
your isnull is doing some after event processing

see my previous comments
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question