Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

loop in trigger Expand / Collapse
Author
Message
Posted Tuesday, December 11, 2012 10:16 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, December 10, 2014 3:54 AM
Points: 157, Visits: 690
hello all.
I have two tables.when insert into one ot them with trigger insert into another and with another trigger insert into first table.that means one loop occurs.waht do i do for solve this loop?
Post #1395425
Posted Tuesday, December 11, 2012 11:17 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, December 2, 2014 9:20 AM
Points: 1,372, Visits: 1,567
Explore Update() function to stop this behavior. Refer the link below:
http://msdn.microsoft.com/en-us/library/ms187326.aspx


~ Lokesh Vij

Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions

Link to my Blog Post --> www.SQLPathy.com

Follow me @Twitter

Post #1395440
Posted Tuesday, December 11, 2012 11:36 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, December 10, 2014 3:54 AM
Points: 157, Visits: 690
thanks for you reply.but please suggest another way.thanks
Post #1395444
Posted Wednesday, December 12, 2012 9:17 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 2:05 PM
Points: 13,327, Visits: 12,820
Your description is extremely vague to say the least. Do you an insert trigger on Table1 that inserts data into Table2? And you also have an insert trigger on Table2 that inserts into Table1? That is what I think you are saying. This is one of the reasons to try to avoid triggers if at all possible. You can't get out of that loop. You need to come up with a different way of doing whatever these triggers are trying to do.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1395753
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse