当从sql server中的linkedserver调用时,from子句中的Sybase子查询不能具有where?

当从sql server中的linkedserver调用时,from子句中的Sybase子查询不能具有where?,sql,sybase,Sql,Sybase,以下sql通过SAP ASE OLE DB提供程序在sql server中工作 select * from openquery(Sybase,' select * from ( select * from X ) x ') 但是,以下方法不起作用。听起来像一只可怕的虫子 select * from openquery(Sybase,' select * from ( select * from X where not exists (selec

以下sql通过SAP ASE OLE DB提供程序在sql server中工作

select * from openquery(Sybase,'
  select * from (
    select * from X
  ) x
')
但是,以下方法不起作用。听起来像一只可怕的虫子

select * from openquery(Sybase,'
    select * from (
      select * from X 
      where not exists (select * from Y where Y.c = X.c) -- c is not key in both tables
    ) x
')

这是重写子查询以使其工作的一种方法吗?它必须在子查询中。或者Sybase链接的服务器驱动程序有问题吗?

如果c是整数且不能是-1,请尝试此驱动程序

select
    *
from
    (   select
            X.*
        from
            X
            left join ( select distinct
                            c
                        from
                            Y) as y on X.c = y.c
            join (  select
                        -1 as c) as z on coalesce(y.c, -1) = z.c
    ) x

否,它失败了,因为子查询中有一个where。因此,将其移到查询外部选择*从选择X.*,y.c作为yc从X左连接选择不同的c从y作为y在X.c=y.c X上,其中yc为Null否,我无法更改外部查询。我只能提供子查询,它将被包装在其他一些外部查询代码中。好的,如果c是整数并且不能是-1,请尝试此操作。从X选择X*从X左连接选择不同的c从Y作为Y在X.c=Y.c连接选择-1作为c作为z在coalescey.c,-1=z.c xYes,连接虚拟表有效。希望它的性能不会太差。