BUG: Regr: Msg 515 When Doing UPDATE w/ISNULL, Agg. & Cor. SbqryLast reviewed: February 17, 1998Article ID: Q179163 |
The information in this article applies to:
SYMPTOMSWith SQL Server 6.5 Service Pack 2 and later, updating a column defined as NOT NULL by using a SELECT statement with ISNULL, an aggregate, and a correlated subquery will generate msg 515 (Attempt to insert the value NULL into column) when there are additional rows in the target table without corresponding rows in the source table.
WORKAROUNDTo work around this problem, do any one of the following;
STATUSMicrosoft has confirmed this to be a problem in SQL Server version 6.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONThe following is an example:
UPDATE TblX SET ColB = (SELECT ISNULL(SUM(ColC),0) FROM TblY WHERE TblX.ColA = TblY.ColA GROUP BY TblY.ColA)This works fine in SQL Server 6.0, 6.5 (release version), and 6.5 Service Pack 1. However, it fails on SQL Server 6.5 Service Packs 2, 3, and 4, as well as on SQL Server build 6.50.285. The example script above will work successfully if any of the following is true:
|
Additional query words: subquery crltd crrltd SUM error set null sp sp1 sp2
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |