November 30, 2010 at 2:32 pm
I am getting the following error:
Msg 156, Level 15, State 1, Line 9
Incorrect syntax near the keyword 'CASE'.
Here is my code...can anyone see what I don't seem to be seeing?
select glbank.check_num
, glbank.ref_num
, glbank.check_amt
, glbank.check_date
, glbank.bank_code
, vendor.vend_num
, vendor.vend_remit
, vendaddr.[name]
CASE
WHEN v.vend_remit IS NULL THEN Left(Upper(IsNull(va.name,'')),75)+Space(75-Len(Left(IsNull(va.name,''),75)))
ELSE Left(Upper(IsNull(vr.name,'')),75)+Space(75-Len(Left(IsNull(vr.name,''),75)))
END
FROM aptrxp_all a
join vendor v
ON a.vend_num = v.vend_num
join vendaddr va
ON a.vend_num = va.vend_num and
left outer join vendaddr vr
ON v.vend_remit = vr.vend_num
left outer JOIN glbank
ON a.check_num=glbank.check_num
WHERE glbank.check_amt = '4935.28'
November 30, 2010 at 2:45 pm
looks like a missing comma before the CASE statement.
I'd also recommend to add an alias to your CASE .. END. 😉
November 30, 2010 at 10:58 pm
Hi
It should be like , or peranthss error.so use Edit++ then u will be findout the problem like where u miss the , or open and close
Thank you very much
Regards
sank
November 30, 2010 at 11:13 pm
LutzM (11/30/2010)
looks like a missing comma before the CASE statement.I'd also recommend to add an alias to your CASE .. END. 😉
apart from the above your code is also
having written wrongley at
ON a.vend_num = va.vend_num and
left outer join vendaddr vr
and after the on statement should be one more condition for the join, noty the other join it self(left outer join vendaddr vr)
November 30, 2010 at 11:17 pm
sharath.chalamgari (11/30/2010)
LutzM (11/30/2010)
looks like a missing comma before the CASE statement.I'd also recommend to add an alias to your CASE .. END. 😉
apart from the above your code is also
having written wrongley at
ON a.vend_num = va.vend_num and
left outer join vendaddr vr
and after the on statement should be one more condition for the join, noty the other join it self(left outer join vendaddr vr)
Just eliminate the and at the end of that line and it should fix that problem.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
December 1, 2010 at 7:03 am
Thanks LutzM...always comes down to a syntax error doesn't it, LOL. And to the other responses, yes I did catch the word "and" which was in there when I was trying something and just forgot to take it out.
Once I added the comma it worked perfectly. Again, thanks for all the responses!
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply