Solved

SQL Update - Update Table from 2 others

Posted on 2013-05-31
3
414 Views
Last Modified: 2013-05-31
Hey Guys
I am looking to update my Parcel Table from the Segment & Street Table using and update trigger.
If Street_Full_Name is updated in Street table
Then update the Parcel Table, Small Catch (Subquery?)

Within the Parcel Table it only holds Segment_ID. Segment_ID is updated manually depending on Parcel locations.
Street_Full_Name is updated in Segment using the following Query
UPDATE Segment
SET Segment.street_Full_Name = st.street_Full_Name,
	from dbo.Street st
                INNER JOIN INSERTED i ON st.OID = i.OID
                INNER JOIN dbo.Segment s ON s.Street_ID = st.Street_ID

Open in new window

Segment connects to Street using the Street_ID
Parcel does not have the Street_ID, It has Segment_ID.
So how do i connect Parcel to Street(which is the base source for the Street_Name_Full column) Using the Segment_ID held in Segment.
3 table join type thing
Thanks
0
Comment
Question by:PtboGiser
3 Comments
 
LVL 32

Accepted Solution

by:
ewangoya earned 500 total points
ID: 39211586
here is the join

select *
from street st
inner join segment s on s.Street_ID = st.Street_ID
inner join parcel p on p.segment_id = s.segment_id

Open in new window

0
 
LVL 26

Expert Comment

by:Zberteoc
ID: 39211661
On what table is the trigger?
0
 

Author Closing Comment

by:PtboGiser
ID: 39211669
thx, i was thinking to complex. Friday afternoon!!!
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

825 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