Solved

Update Trigger

Posted on 2013-01-25
2
268 Views
Last Modified: 2013-02-05
I would like to pull the Street_Full_Name and AnnoName columns from my Street Table Where StreetID in the Segment Table = StreetId in the Street Table when there has been a insertion or Update on my Street.
AS well i will need it to fire or a separate Trigger to fire when there has been and insertion or Update on the Segment table
How best to handle something like ?
Segment Table Trigger(which is not working)
ALTER TRIGGER [dbo].[FName_AName_Num_Las<wbr ></wbr>tdate_Cont<wbr ></wbr>_Segment] ON [dbo].[Segment]
    AFTER INSERT, UPDATE
AS
    BEGIN
        SET NOCOUNT ON;

       UPDATE Segment
        SET     Street_Full_Name = st.Street_Full_Name,
                AnnoName = st.AnnoName
        FROM    dbo.Segment s
                INNER JOIN INSERTED i ON s.OID = i.OID
                INNER JOIN dbo.Street st ON s.Street_ID = st.Street_ID

    END

Open in new window

0
Comment
Question by:PtboGiser
2 Comments
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
Comment Utility
You need to put a INSERT UPDATE trigger on dbo.Street  and that action will fire the triggers on dbo.Segment but you also need to make sure the recursive trigger SQL setting is on:

http://msdn.microsoft.com/en-us/library/ms188124(v=sql.100).aspx
0
 

Author Comment

by:PtboGiser
Comment Utility
I've requested that this question be deleted for the following reason:

thx
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now