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 2000 Forums
 Transact-SQL (2000)
 On Update insert into Trigger..

Author  Topic 

cblatchford
Starting Member

40 Posts

Posted - 2006-01-10 : 11:05:34
Hi chaps,

Could someone show me how to compile a trigger which inserts the modified row into another table? I have the following currently..

CREATE TRIGGER [PeopleUpdate] ON [dbo].[People]
FOR UPDATE, DELETE, INSERT
AS
insert into peopleupdate (pplfirstname, updatetime)
select (pplfirstname) as pplfirstname, getdate() from people

This simply returns all the entries in the people table!

Thanks

CB


cblatchford
Starting Member

40 Posts

Posted - 2006-01-10 : 11:17:14
..so for example if someone updates/deletes/inserts a record in the people table, I want that same record to be inserted into a new table, peopleupdate.
Go to Top of Page

cblatchford
Starting Member

40 Posts

Posted - 2006-01-10 : 11:25:47
OK, obviously i was missing the "from inserted" code...oh dear :-)
Go to Top of Page
   

- Advertisement -