?
Solved

Help with update query

Posted on 2008-10-29
3
Medium Priority
?
234 Views
Last Modified: 2012-05-05
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)
0
Comment
Question by:edrz01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 22830235
this will work better:
use netperfmon
UPDATE n
  set totalports = c.totalports,
  freeports=c.freeports
from dbo.nodes n
join [MyServer]...[truecontrol.rn_device] as C
  on N.caption = c.hostname

Open in new window

0
 

Author Closing Comment

by:edrz01
ID: 31511116
Once again, right on.  Looks like I need to spend a little more time on my SQL sysntax review....
THANKS!
0
 
LVL 9

Expert Comment

by:jamesgu
ID: 22830291
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
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question