Question

Why MS-SQL does not throw error in this select? There is no Document_ID field in #aa table.

 CREATE TABLE docs
 (
  Document_ID uniqueidentifier
 )

 SELECT 0x00 Document_XX
 INTO #aa


 SELECT * 
 FROM docs
 WHERE Document_ID IN (SELECT Document_ID FROM #aa)
Était-ce utile?

La solution

The Document_ID in SELECT Document_ID FROM #aa would just resolve to the docs.Document_ID

It would be the same as

SELECT * 
FROM docs d
WHERE Document_ID IN (SELECT d.Document_ID FROM #aa)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top