ORACLE/SQL Server 中的减法与除外差异

2021-12-24 00:00:00 tsql oracle sql-server plsql

MINUS 是一个 SQL 集合操作,它从第一个表中选择元素,然后删除 Oracle 中第二个 SELECT 语句也返回的行.而在 SQL Server 中,我们可以使用 EXCEPT 来做同样的事情.

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 Server, we can use EXCEPT to do same thing.

在将我的项目从 oracle 迁移到 SQL Server 时,我注意到了不同之处.如果第一个结果集没有记录,则减去第二个 SELECT 语句的结果集.但在 SQL Server 中,EXCEPT 不返回任何内容.在这种情况下我能做什么?我正在迁移我的项目并希望在 SQL Server 中执行相同的减号功能.

While migrating my project from oracle to SQL Server, I noticed a difference. If first result set doesn't have records, minus brings result set of second SELECT Statement. But in SQL Server, EXCEPT returns nothing. What can I do in that case? I am migrating my project and want to do same of minus function in SQL Server.

感谢您的帮助

推荐答案

Oracle MINUS 和 SQL Server EXCEPT 没有区别.

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(搜索 MINUS 运算符),阅读说明, 完全匹配 SQL Server 的 EXCEPT)
  • Oracle MINUS 与 SQL Server 除外(比较文档)
  • 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)

相关文章