Link to home
Start Free TrialLog in
Avatar of edrz01
edrz01Flag for United States of America

asked on

Help with update query

This has to got to be so simple but I can't get it to work....
I am trying to update 2 fields per record based on the results of a query. I can run the query by itself and it returns the data but when i add the update piece it balks about a ")" issue. I can't seem to find out why or where to put the closing ")". What am I missing???

use netperfmon
UPDATE dbo.nodes
set totalports = c.totalports,
freeports=c.freeports
from (
SELECT c.totalports, c.freeports
FROM [MyServer]...[truecontrol.rn_device] as C
JOIN dbo.nodes as N
on N.caption = c.hostname)
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of edrz01

ASKER

Once again, right on.  Looks like I need to spend a little more time on my SQL sysntax review....
THANKS!
Avatar of jamesgu
jamesgu

c is not visible from outside of the brackets, and the update clause expects an alias of the derived table

try this

use netperfmon
UPDATE dbo.nodes
set totalports = tt.totalports,
freeports=tt.freeports
from (
SELECT c.totalports, c.freeports
FROM [MyServer]...[truecontrol.rn_device] as C
JOIN dbo.nodes as N
on N.caption = c.hostname) tt