Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oracle到SQL Server转换错误_Sql_Sql Server_Database Migration - Fatal编程技术网

Oracle到SQL Server转换错误

Oracle到SQL Server转换错误,sql,sql-server,database-migration,Sql,Sql Server,Database Migration,我在oracle中遇到了一个特殊情况,我正试图在MS SQL Server中运行该情况,但出现了问题 这是代码 select a.*,b.* from a left join b on a.id = b.id and (a.id,b.name) in ( select distinct id,name from master where record = 'Active') 我在第3行得到一个错误,它说: 在上下文中指定的非布尔类型的表达式,其中 条

我在oracle中遇到了一个特殊情况,我正试图在MS SQL Server中运行该情况,但出现了问题

这是代码

select a.*,b.*
from a
  left join b on a.id = b.id
  and (a.id,b.name) in
        ( select distinct id,name
          from master where record = 'Active')
我在第3行得到一个错误,它说:

在上下文中指定的非布尔类型的表达式,其中 条件是预期的,在“,”附近


请帮助你不能这样写
(a.id,b.name)


你不能这样写(a.id,b.name)


您需要将其重写为
存在
条件:

select a.*,b.*
from a
  left join b on a.id = b.id
  and exists (select * 
              from master m
              where m.record = 'Active'
                and m.id = a.id 
                and m.name = b.name)

您需要将其重写为
存在
条件:

select a.*,b.*
from a
  left join b on a.id = b.id
  and exists (select * 
              from master m
              where m.record = 'Active'
                and m.id = a.id 
                and m.name = b.name)


子查询中的两个表达式
?不相关的id和名称条件@jarlh id和名称条件如何不相关?主表可能包含一个活动行和另一个id行。
子查询中的两个表达式
?不相关的id和名称条件@jarlh id和名称条件如何无关?主表可能包含一个活动行和另一个id行。Oracle或SQL Server?我认为在Oracle上,这个查询应该是有效的。
DISTINCT
是无用的。这只会降低性能。从Oracle或SQL server到SQL server?我认为在Oracle上,这个查询应该是有效的。
DISTINCT
是无用的。它只会降低性能。对于Oracle中的SQL server,请注意,
在(…)
中的行为不同于
EXIST
中的空值(至少在Oracle中)。由于查询使用了
左外部联接
,这意味着
b.name
可能为空。@WernfriedDomscheit:我认为这没有什么区别。子句中的
也使用
=
来比较列值。因此,例如(…)
中的
(42,null),其中子选择返回的null值也不会被包括在内,就像
存在一样
solution@WernfriedDomscheit:请参见此处:请注意,(…)
中的
行为与空值的
EXIST
不同(至少在Oracle中是这样)。由于查询使用了
左外部联接
,这意味着
b.name
可能为空。@WernfriedDomscheit:我认为这没有什么区别。
子句中的
也使用
=
来比较列值。因此,例如(…)
中的
(42,null),其中子选择返回的null值也不会被包括在内,就像
存在一样
solution@WernfriedDomscheit:见此: