SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Insert all records in another table using triggers
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

shinelawrence
Starting Member

India
32 Posts

Posted - 04/19/2013 :  02:02:25  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 04/19/2013 :  02:25:46  Show Profile  Reply with Quote
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

India
32 Posts

Posted - 04/19/2013 :  02:27:56  Show Profile  Reply with Quote
oh...k...thank u very much...

Lawce
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 04/19/2013 :  02:41:37  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.95 seconds. Powered By: Snitz Forums 2000