Minus vs Except Difference in ORACLE/SQL Server

前端 未结 2 1199
天涯浪人
天涯浪人 2020-12-14 18:26

MINUS is a SQL set operation that selects elements from the first table and then removes rows that are also returned by the second SELECT statement in Oracle. And in SQL Ser

相关标签:
2条回答
  • 2020-12-14 18:31

    This will check for any result set from the first query, then run the except if there is a result. If not it only runs the second query.

    IF EXISTS (SELECT NULL
               FROM ... <first query criteria>
               WHERE ...)
    BEGIN
        SELECT ... <first query>
        EXCEPT 
        SELECT ... <second query>
    END
    ELSE
    SELECT ... <second query>
    
    0 讨论(0)
  • 2020-12-14 18:42

    There is no difference between Oracle MINUS and SQL Server EXCEPT.

    They are intended to do the same thing.

    • http://dotnetguts.blogspot.com/2008/04/minus-keyword-in-sql-server.html
    • http://blog.sqlauthority.com/2008/08/07/sql-server-except-clause-in-sql-server-is-similar-to-minus-clause-in-oracle/
    • http://vyaskn.tripod.com/oracle_sql_server_differences_equivalents.htm (search for MINUS operator), read the description, which matches EXCEPT for SQL Server exactly)
    • Oracle MINUS vs SQL Server EXCEPT (compare docs)
    0 讨论(0)
提交回复
热议问题