Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Trigger update

Author  Topic 

monadel
Starting Member

3 Posts

Posted - 2009-01-19 : 17:59:13
Hi All,

I have a problem creating a new trigger here.
I am a new with trigger.
I want to create a simple trigger to automatic update a field on Table B when I update a data field on table A.
For example Table A have docID, firstname
Table B have docID, fname.

docID will be connection between table A and B.

Could anyone help me and show me a working trigger like a describe above please?

Thank you

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-20 : 01:57:48
Homework?
CREATE TRIGGER	dbo.trgTableA_Update
ON TableA
AFTER UPDATE
AS

UPDATE b
SET b.fName = i.FirstName
FROM TableB AS b
INNER JOIN inserted AS i ON i.docID = b.docID



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-20 : 02:36:17
suggest you to refer to books online about triggers to understand how they work and also significance of inserted,deleted table
Go to Top of Page
   

- Advertisement -