Tuesday, February 1, 2011

Null value is eliminated by an aggregate or other SET operation.

Null value is eliminated by an aggregate or other SET operation
You get this error while executing SQL statement or stored procedure, if you use aggregate function like sum, max, min etc on a column which contains NULL value.
Example:
SET @METRIC_ID = (SELECT MAX(Convert(int,Metric_ID))+1 from [WEB].[TMS_TOP_PROGRAMS_ENTRY]);
Change above statement with this to get rid of above warning (ANSI):
SET @Metric_ID = (SELECT MAX(Convert(int,isnull(Metric_ID,0)))+1 from [WEB].[TMS_TOP_PROGRAMS_ENTRY]);

No comments:

Post a Comment