0

Could someone please explain why the following query runs and does not return an error in SQL server 2012? When column BADCOLUMN does not exist in Table sometable?

SELECT  et
       ,mdt
FROM csv_import as a
where et IN (2,73) 
  AND siteid IN (
                 select BADCOLUMN
                 from sometable
                  where SN in ('a','b','c')
                )

If you run just the subquery

select BADCOLUMN 
from sometable 
where SN in ('a','b','c')

You will receive an error stating the column does not exist. But if you run the full query you will not receive an error and that section of the where clause gets ignored

To me the full query should not run as a section of it contains an error? Opinions or Reasons?

M.Ali
  • 67,945
  • 13
  • 101
  • 127
tbdevmanager
  • 373
  • 5
  • 15

0 Answers0