.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

Trigger in sql server 2005

Posted By: Dom     Posted Date: January 08, 2010    Points:2   Category :Sql Server
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

Responses
Author: Amit Mehra             
Posted Date: January 08, 2010     Points: 5   

Hi,

Please refer this article this may help you..

http://www.dotnetspark.com/kb/1151-triggers-sql.aspx

Thanks
Amit

Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Lalij Mer             
Posted Date: January 08, 2010     Points: 5   

try this code

CREATE TABLE dbo.tab1 (celsius int)
CREATE TABLE dbo.tab2 (fahrenheit int ) -- to show that data can be transformed in the trigger
GO
CREATE TRIGGER myInsertTrigger
ON dbo.tab1
FOR INSERT AS
-- inserted is a special table containing the inserted records.
INSERT INTO dbo.tab2 SELECT (col1*9)/5+32 FROM inserted

GO
INSERT dbo.tab1(celsius) VALUES(37)
GO
-- Confirm that the insert into tab1 has propagated to tab2.
SELECT * FROM dbo.tab2
GO


Insert Multiple Records Using One Insert Statement - Use of UNION ALL
------------
http://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/

http://stackoverflow.com/questions/175066/sql-server-is-it-possible-to-insert-into-two-tables-at-the-same-time

Please Check my answer if you help....
Thank You...

Lalit.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend