Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

Converting of ORACLE SQL Update statement into T-SQL statement

Here is Oracle's syntax. Can somebody convert it into MS SQL server syntax? I really don't know how to do it.

update NSZ N
set POV = POV_BCK
where PC_MID in
      (select PC_MID
      from NSZ
      where POV != cast (POV_ORIG as NUMERIC(15,2))
      group by pc_mid
      having count(*)>1)
  and POV_ORIG = (
       SELECT  max (POV_ORIG)
         from NSZ
         where PC_MID = N.PC_MID)   -- HERE IS THE PROBLEM !
0
tomaz108
Asked:
tomaz108
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
update NSZ N
set POV = POV_BCK
where PC_MID in
     (select PC_MID
     from NSZ
     where POV <> cast (POV_ORIG as NUMERIC(15,2) )
     group by pc_mid
     having count(*)>1 )
  and POV_ORIG = (
      SELECT  max (i.POV_ORIG)
        from NSZ I
        where I.PC_MID = N.PC_MID)   -- HERE IS THE PROBLEM !
0
 
tomaz108Author Commented:
doesn't work:

Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'N'.
Msg 156, Level 15, State 1, Line 9
Incorrect syntax near the keyword 'and'.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I see:

update NSZ
set POV = N.POV_BCK
FROM NSZ N
where PC_MID in
     (select PC_MID
     from NSZ
     where POV <> cast (POV_ORIG as NUMERIC(15,2) )
     group by pc_mid
     having count(*)>1 )
  and POV_ORIG = (
      SELECT  max (i.POV_ORIG)
        from NSZ I
        where I.PC_MID = N.PC_MID)  
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now