?
Solved

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

Posted on 2009-05-03
2
Medium Priority
?
249 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 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