Solved

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

Posted on 2011-03-08
5
558 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now