T-SQL: Comparing Two Tables - Records that don't exist in second table

前端 未结 7 1367
小鲜肉
小鲜肉 2021-01-02 05:05

If UNION ALL is an addition in T-SQL. What is the equivalent of subtraction?

For example, if I have a table PEOPLE and a table

7条回答
  •  青春惊慌失措
    2021-01-02 06:03

    Instead of using UNION, use EXCEPT, ( or INTERSECT to get only records in both ) as described in

    msdn EXCEPT Link for Sql2k8

    msdn EXCEPT Link for Sql2k5

提交回复
热议问题