[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do I update a table from a linked table in Ms sql 2000

Posted on 2009-05-03
2
Medium Priority
?
250 Views
Last Modified: 2012-05-06
My update code doesnt work.
Tblsite links to tbladdress
tempmarketing2 links on postcode to tbladdress

this works as a select statement but the update statement below fails

SELECT tblAddress.Address_PostZip AS Expr1, tblSite.Site_Name AS Expr2, TempMarketing2.siteid AS Expr3, tblSite.Site_ID AS Expr4,
       TempMarketing2.company AS Expr5, *
  FROM TempMarketing2
 INNER JOIN tblAddress ON tblAddress.Address_PostZip = TempMarketing2.epostcod AND TempMarketing2.epostcod = tblAddress.Address_PostZip
 INNER JOIN tblSite ON tblAddress.Address_ID = tblSite.Site_Address AND LEFT(TempMarketing2.Company,1) = LEFT(tblSite.SITE_NAME,1)
 WHERE (tblSite.Site_Active = 1)
 ORDER BY TempMarketing2.epostcod, TempMarketing2.company, tblSite.Site_Name
Update TempMarketing2 
set siteid=tblsite.site_id
from tblsite
INNER JOIN tblAddress ON tblAddress.Address_PostZip = TempMarketing2.epostcod AND TempMarketing2.epostcod = tblAddress.Address_PostZip 
INNER JOIN tblSite ON tblAddress.Address_ID = tblSite.Site_Address AND LEFT(TempMarketing2.Company,1) = LEFT(tblSite.SITE_NAME,1)
 WHERE (tblSite.Site_Active = 1)

Open in new window

0
Comment
Question by:Chris Michalczuk
[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
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 750 total points
ID: 24290805
you must join the UPDATE also#:
Update tm
set siteid=ts.site_id
from TempMarketing2 tm
INNER JOIN tblAddress a 
  ON a.Address_PostZip = tm.epostcod 
 AND tm.epostcod = a.Address_PostZip 
INNER JOIN tblSite ts 
  ON a.Address_ID = ts.Site_Address 
 AND LEFT(tm.Company,1) = LEFT(ts.SITE_NAME,1)
 and ts.Site_Active = 1

Open in new window

0
 

Author Closing Comment

by:Chris Michalczuk
ID: 31577358
hard to follow
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 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