Bijesh
3/9/2007 4:24:00 PM
Hi All,
I am facing a wierd problem condition where SQL compiler is not trapping
compile/run time error.
Here is an example to illustrate:
Create Table Table1
(
Col1 INT
)
Go
Create Table Table2
(
Coll1 INT --Note an extra "L" in the column name.
)
Go
Now fire this query:
Select * from Table1 Where Col1 IN (Select Col1 From Table2)
--(0 row(s) affected)
Though column "Col1" does not exist in Table2, it does not throw any error.
But when we fire the following query, it does throw error
Select * from Table1 Where Col1 IN (Select xyz From Table2)
Server: Msg 207, Level 16, State 3, Line 1
Invalid column name 'xyz'.
Observation:
It is noted that when the column name in "Where" condition of Table1 is used
inside the subquery(Table2) it does not throw error. But when some other name
such as 'xyz' is used in subquery, it throws error.
Also, this error is not trapped when compiling SP.
Can someone help explain this to me? I am using SQL Server 2000 Enterprise
edition.
Thanks in advance.
Bijesh