When to use EXCEPT as opposed to NOT EXISTS in Transact SQL?

后端 未结 5 1310
甜味超标
甜味超标 2020-11-30 05:45

I just recently learned of the existence of the new \"EXCEPT\" clause in SQL Server (a bit late, I know...) thru reading code written by a coworker. It truly amazed me!

5条回答
  •  猫巷女王i
    2020-11-30 06:08

    EXCEPT compares all (paired)columns of two full-selects. NOT EXISTS compares two or more tables accoding to the conditions specified in WHERE clause in the sub-query following NOT EXISTS keyword.

    EXCEPT can be rewritten by using NOT EXISTS. (EXCEPT ALL can be rewritten by using ROW_NUMBER and NOT EXISTS.)

    Got this from here

提交回复
热议问题