简体   繁体   中英

Why am I getting syntax error of bracket?

I have the following sql query:

\
(
Msg 102, Level 15, State 1, Line 16
Incorrect syntax near ')'.

Everything seems correct. but dont know why this error?

This isn't an answer. Rather it demonstrates what happens after considering all the comments. Here is your query after editing and formatting for readability. Warning - DISTINCT is often a kludge to cover up a logic or schema fault.

select distinct Baan1.t_pono, Baan1.t_oqua, Baan1.t_eono, 
       Baan1.t_odat, Baan2.t_bano, Baan2.t_orno, Baan2.t_send, Baan3.t_cuno 

  from BAAN1.baandb.dbo.ttdsls04020 Baan1 
  join [M3].[v850_Staging] Mthree on
       Mthree.PONum1 collate DATABASE_DEFAULT = Baan1.t_eono collate DATABASE_DEFAULT

  join BAAN1.baandb.dbo.ttcedi702200 Baan2 
       <see anything wrong here?>

  join [M3].[v850_Staging] Mthree on
       Mthree.PONum1 collate DATABASE_DEFAULT = Baan2.t_bano collate DATABASE_DEFAULT

  join BAAN1.[baandb].[dbo].[ttcedi010200] Baan3 on 
       Mthree.Relation collate DATABASE_DEFAULT = Baan3.t_reno collate DATABASE_DEFAULT

<lack of ORDER BY clause is usually a fault>
<I added a statement terminator - which is a good habit you should develop
;

Notice that columns from Mthree are not used in the select list. Notice also that alias MThree is defined TWICE. It is odd that a "staging" table (view?) in one database is used to relate rows between tables in another database. Seems much more work is needed that goes beyond basic syntax issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM