Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Invalid column name in @tablevariable not throwing error

$
0
0

DECLARE @IDListAll TABLE (allID INT) DECLARE @filterList TABLE (debtID VARCHAR(200))

INSERT INTO @IDListAll ( allID ) VALUES (397243),(397245),(397249),(397250),(397252),(397253),(397254),(397255),(403259),(404704),(404709),(500008399) INSERT INTO @filterList( debtID ) VALUES ( 12 ) SELECT * FROM @IDListAll WHERE allID IN (SELECT allID FROM @filterList)

In the code above, I have 2 table variables @IDListAll & @filterList. @filterList table does not have the column allId in it, but the select statement does not throw an error but returns the table @IDListAll. Isn't this weird? 

I am trying to re factor some old code in the database and found this one. This is wrapped in a stored proc and the stored proc generates no error when this is run.

I ran the above code using temp tables, does the same thing.

Can anyone explain this behavior of sql server? 


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>