tags:

views:

43

answers:

4

I want to create trigger for one table for insertion...If i insert records in one table then that same records should be inserted to another one......how?

and also explain about triggers

A: 

Please have a read of Exploring SQL Server Triggers

Mitch Wheat
A: 

This article covers all the basics of creating triggers.

Though for you task i think a stored procedure doing both inserts will be better, because what if one insert succeeded and the other failed? it will create inconsistency in your data. See here for stored procedures.

Am
+1  A: 

It should be something like

CREATE TRIGGER TableInserted ON TableInsert
AFTER INSERT
AS
INSERT INTO OtherTable SELECT * FROM inserted
astander
+2  A: 

All you need to know about triggers, without having to wade through Microsoft speak, including how to create them in SQL Server.

http://en.wikipedia.org/wiki/Database_trigger

Jason
"wade through Microsoft speak"? - presumably the guys that designed and wrote the mechanisms, are able to explain them
Mitch Wheat
agreed, but to someone who is just starting out, it might not be the easiest to understand
Jason