Trigger Help - NewBie

Last Post 07 Aug 2007 11:01 AM by gems22. 0 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
gems22
New Member
New Member

--
07 Aug 2007 11:01 AM
Hi All,

This is my first time writing a trigger in SQL Server 2000. Needed some guidance with syntax. I have a table(table1) with exact same copy(table2) in a different database. The only difference in the table structure being that two fields from table1 are concatenated into one in table2.
I want to write a trigger that will keep table2 in sync with table1. Whether it's an insert, delete or an update on table1, table2 should be the same. Need some help with the syntax.

This is what I have so far..I am little confused about insert/update syntax. Any help will be highly appreciated.

CREATE TRIGGER TRG_DC ON [dbo].[TABLE1]
FOR INSERT, UPDATE, DELETE
AS

DECLARE @DC VARCHAR(5)
SELECT @DC = (SELECT do_group+do_ssc FROM INSERTED)

DELETE FROM TABLE2
WHERE ID IN (SELECT ID FROM DELETED)

Thx
You are not authorized to post a reply.

Acceptable Use Policy