Solved

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

Posted on 2009-05-03
2
247 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 250 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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

691 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