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 2008 Forums
 Transact-SQL (2008)
 Insert all records in another table using triggers

Author  Topic 

shinelawrence
Starting Member

32 Posts

Posted - 2013-04-19 : 02:02:25
Hi Everyone,
If i inserted 10 or more than records inserted in one table when i insert one table then automatically insert in another table. I used trigger but first row insert in another table. How to insert all the records.. Please tell the solution...

Thanks In Advanced

Lawce

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-19 : 02:25:46
something like

CREATE TRIGGER TriggerName
ON Table1
AFTER INSERT
AS
BEGIN
INSERT INTO Table2
SELECT *
FROM INSERTED
END


I'm assuming both tables have same structure otherwise you've specify column list in INSERT and SELECT

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

shinelawrence
Starting Member

32 Posts

Posted - 2013-04-19 : 02:27:56
oh...k...thank u very much...

Lawce
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-19 : 02:41:37
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -