Microsoft KB Archive/229888

= INF: Subquery Column Can Be Resolved as Outer Query Column =

Article ID: 229888

Article Last Modified on 11/14/2003

-

APPLIES TO


 * Microsoft SQL Server 6.5 Standard Edition
 * Microsoft SQL Server 7.0 Standard Edition
 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q229888



SUMMARY
When a column in a subquery does not exist in the table referenced in the subquery, the column can resolve to a table in the outerquery.

The following script demonstrates this behavior: DROP TABLE test1 GO DROP TABLE test2 GO CREATE TABLE test1 (col1 INT, col2 INT) GO CREATE TABLE test2 (col3 INT, col4 INT) GO INSERT INTO test1 VALUES(1,1) INSERT INTO test1 VALUES(2,2) INSERT INTO test1 VALUES(3,3) INSERT INTO test1 VALUES(4,4) INSERT INTO test1 VALUES(5,5) INSERT INTO test2 VALUES(1,1) INSERT INTO test2 VALUES(2,2) INSERT INTO test2 VALUES(3,3) INSERT INTO test2 VALUES(4,4) INSERT INTO test2 VALUES(5,5) GO SELECT * FROM test1 GO DELETE test1 WHERE col1 IN (SELECT col1 FROM test2 WHERE col4=1) GO SELECT * FROM test1 GO



MORE INFORMATION
Explicitly qualify the column names inside the subquery to override implicit assumptions about table names.

Keywords: kbinfo kbpending KB229888

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.