debugsqlModerate
Meaning of 'SET' in error message 'Null value is eliminated by an aggregate or other SET operation'
Viewed 0 times
meaningerrornullmessagevalueoperationaggregateotherseteliminated
Problem
I saw the above 'ANSI warning' message today when running a colleague's script (and I don't know which of the many statements caused the warning to be shown).
In the past I've ignored it: I avoid nulls myself and so anything that would eliminate them is a good thing in my book! However, today the word 'SET' literally shouted out at me and I realised I don't know what the meaning of the word is supposed to be in this context.
My first thought, based on the fact it is upper case, is that it is referring to the
According to the SQL Server Help, the 'ANSI warnings' feature is based on ISO/ANSI SQL-92, the spec for which makes just one use of the term 'Set operation' in a subsection title, hence in title case, in the data assignment section. However, after a quick Googling of the error message I see examples that are
My second thought, based on the wording of the SQL Server warning, was that the mathematical meaning of set is implied. However, I don't think that aggregation in SQL is strictly speaking a set operation. Even if the SQL Server team consider it to be a set operation, what is the purpose of putting the word 'set' in capitals?
While Googling I noticed a SQL Server error message:
The same words 'SET operation' in the same case here can only refer to the assignment of the
Can anyone shed any light on the matter?
In the past I've ignored it: I avoid nulls myself and so anything that would eliminate them is a good thing in my book! However, today the word 'SET' literally shouted out at me and I realised I don't know what the meaning of the word is supposed to be in this context.
My first thought, based on the fact it is upper case, is that it is referring to the
SET keyword and means 'assignment', as in UPDATE SET ...
...ON DELETE SET NULL...
SET IDENTITY_INSERT ONAccording to the SQL Server Help, the 'ANSI warnings' feature is based on ISO/ANSI SQL-92, the spec for which makes just one use of the term 'Set operation' in a subsection title, hence in title case, in the data assignment section. However, after a quick Googling of the error message I see examples that are
SELECT queries with seemingly no assignment involved.My second thought, based on the wording of the SQL Server warning, was that the mathematical meaning of set is implied. However, I don't think that aggregation in SQL is strictly speaking a set operation. Even if the SQL Server team consider it to be a set operation, what is the purpose of putting the word 'set' in capitals?
While Googling I noticed a SQL Server error message:
Table 'T' does not have the identity property. Cannot perform SET operation.The same words 'SET operation' in the same case here can only refer to the assignment of the
IDENTITY_INSERT property, which brings me back to my first thought.Can anyone shed any light on the matter?
Solution
I was just looking through the SQL-92 Specification and saw a passage that reminded me of this question.
There is in fact a prescribed warning for this situation as indicated below
b) Otherwise, let TX be the single-column table that is the
result of applying the `
There is in fact a prescribed warning for this situation as indicated below
b) Otherwise, let TX be the single-column table that is the
result of applying the `
to each row of T
and eliminating null values. If one or more null values are
eliminated, then a completion condition is raised: warning-
null value eliminated in set function.
I assume that the SET` in the SQL Server Error Message is a reference to the set function of that error message although I'm not sure why it would make a distinction between aggregates and other set functions, as far as I can see they are synonymous. The relevant bit of the grammar is below.6.5
Function
Specify a value derived by the application of a function to an
argument.
Format
::=
COUNT
|
::=
[ ]
::=
AVG | MAX | MIN | SUM | COUNT
::= DISTINCT | ALLCode Snippets
6.5 <set function specification>
Function
Specify a value derived by the application of a function to an
argument.
Format
<set function specification> ::=
COUNT <left paren> <asterisk> <right paren>
| <general set function>
<general set function> ::=
<set function type>
<left paren> [ <set quantifier> ] <value expression> <right paren>
<set function type> ::=
AVG | MAX | MIN | SUM | COUNT
<set quantifier> ::= DISTINCT | ALLContext
StackExchange Database Administrators Q#10952, answer score: 14
Revisions (0)
No revisions yet.