Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 nn-boolean type

Author  Topic 

tariq2
Posting Yak Master

125 Posts

Posted - 2011-06-18 : 01:54:00
Thankyou in advance

With the below query I am receiving the following error:

Msg 4145, Level 15, State 1, Procedure tisp_budgetcheck, Line 23
An expression of non-boolean type specified in a context where a condition is expected, near ','.



select * from BIProd.dbo.D_Accounts where LEID,l5account in
(
select a.leid,a.obj from iplan.dbo.upload_generalexpensetest a left outer join BIProd.dbo.D_Accounts b
on a.LEID = b.LEID
and a.OBJ = b.L5Account
and a.SUB = b.L5Sub
where a.LEID between @leid1 and @leid2
and( b.L5Account is null or b.L5Sub is null or b.LEID is null)
)

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-06-18 : 06:23:08
The following will fix the parser error. What is the logic you are trying to implement?
select * from BIProd.dbo.D_Accounts where LEID, l5account in 
(
select a.leid,a.obj from iplan.dbo.upload_generalexpensetest a left outer join BIProd.dbo.D_Accounts b
on a.LEID = b.LEID
and a.OBJ = b.L5Account
and a.SUB = b.L5Sub
where a.LEID between @leid1 and @leid2
and( b.L5Account is null or b.L5Sub is null or b.LEID is null)
)
Go to Top of Page

tariq2
Posting Yak Master

125 Posts

Posted - 2011-06-18 : 07:03:44
Hi Sunita,

Thank you for the reply. I am trying to retrieve all the entries in d_accounts where the leid,l5account combination
is the same as that within the subquery.

I hope this is of help
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-06-18 : 07:26:42
In that case, perhaps it would be best to do it using the EXISTS clause:
select * from BIProd.dbo.D_Accounts X where 
exists

(
select * from iplan.dbo.upload_generalexpensetest a left outer join BIProd.dbo.D_Accounts b
on a.LEID = b.LEID
and a.OBJ = b.L5Account
and a.SUB = b.L5Sub
where a.LEID between @leid1 and @leid2
and( b.L5Account is null or b.L5Sub is null or b.LEID is null)
and X.LEID = a.leid and X.l5account = a.obj

)
Alternatively, you could use an inner join as shown below. Not sure which one will be more efficient.
select * from BIProd.dbo.D_Accounts X inner join
(
select distinct a.leid,a.obj from iplan.dbo.upload_generalexpensetest a left outer join BIProd.dbo.D_Accounts b
on a.LEID = b.LEID
and a.OBJ = b.L5Account
and a.SUB = b.L5Sub
where a.LEID between @leid1 and @leid2
and( b.L5Account is null or b.L5Sub is null or b.LEID is null)

) Y on X.leid = Y.LEID and x.l5account = Y.obj
Go to Top of Page

tariq2
Posting Yak Master

125 Posts

Posted - 2011-06-20 : 04:40:59
Sunita,
Very helpful
Many thanks for your response :)
Go to Top of Page
   

- Advertisement -