UPDATE query with an inner join

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maxamis4
    Recognized Expert Contributor
    • Jan 2007
    • 295

    #1

    UPDATE query with an inner join

    I have the following query that I am trying to carry over from ms access to ms sql server. I keep getting a msg 156, level 15, state 1, line 2 Incorrect syntax near the keyword "INNER".

    it works in ms access and I am not sure why its not working on this side.
    Code:
    UPDATE 
    dbo.cr_stat INNER JOIN (dbo.call_req INNER JOIN dbo.z_tbl_D_26_Time_To_Resolve_CR ON 
    dbo.call_req.persid = dbo.z_tbl_D_26_Time_To_Resolve_CR.CR_Persid) ON 
    dbo.cr_stat.code = dbo.call_req.status 
    SET dbo.z_tbl_D_26_Time_To_Resolve_CR.status = dbo.cr_stat.sym;

    Any help would be appreciated.
  • maxamis4
    Recognized Expert Contributor
    • Jan 2007
    • 295

    #2
    I have figured it out. I needed to incorporate the from statement at the end of the query. If this is incorrect please let me know.

    here is my new code

    Code:
    UPDATE dbo.z_tbl_D_26_Time_To_Resolve_CR
    SET dbo.z_tbl_D_26_Time_To_Resolve_CR.status = dbo.cr_stat.sym
    FROM dbo.cr_stat INNER JOIN (dbo.call_req INNER JOIN dbo.z_tbl_D_26_Time_To_Resolve_CR ON 
    dbo.call_req.persid = dbo.z_tbl_D_26_Time_To_Resolve_CR.CR_Persid) ON 
    dbo.cr_stat.code = dbo.call_req.status

    Comment

    Working...