user3024635
user3024635

Reputation: 89

Oracle to SQL Server conversion error

I have a particular condition in oracle which I am trying to run in MS SQL Server, but having issues..

Here is the code...

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')

I am getting the error in line 3 where it says:

An expression of non-boolean type specified in a context where a condition is expected, near ','.

Pls help

Upvotes: 0

Views: 102

Answers (2)

user330315
user330315

Reputation:

You need to rewrite that into an EXISTS condition:

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)

Upvotes: 2

Jay Shankar Gupta
Jay Shankar Gupta

Reputation: 6088

You can't write like this (a.id,b.name)

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

Upvotes: 0

Related Questions