.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 fire wrong data to table problem

Posted By: Balwant     Posted Date: March 23, 2011    Points:5   Category :Sql Server
i create a trigger on table after insert and insert the data from current table to new table using temp INSERTED table. Data is inserted but some column data is not correct. for example i have distance column in both old and new table and suppose in one row of old table i inserted new record with distance 34.45 but after trigger is fired the new table's distance column have 37.21.

i don't understand what is the problem and how to get rid of it.
Please help me.

Responses
Author: Sunil Yadav       [Moderator]      
Posted Date: March 23, 2011     Points: 20   

HI,

Seems like when you are adding data in the table, the insert query adds the data in another column.

Share your code so that we can help you resolve this issue.


Author: Karthikeyan Anbarasan       [Moderator]      
Posted Date: March 23, 2011     Points: 20   

Hi,

Please post your trigger statement code...we can check on that

Thanks
Karthik
http://www.f5debug.net
Mark as Answer if the answer solves your issue!!!
Author: Balwant             
Posted Date: March 23, 2011     Points: 20   

the trigger is simple and the code for trigger is as below:

CREATE TRIGGER [dbo].[Shortest_Exit_Path]
ON [dbo].[Exit_Path]
AFTER INSERT
AS
IF (@@RowCount > 0)
BEGIN

INSERT into Shortest_Exit_Path([ProjectId]
,[ExitPath]
,[PhysicalExitPath]
,[ExitPathCoordinates]
,[Distance]
)
SELECT [ProjectId]

,[ExitPath]
,[PhysicalExitPath]
,[ExitPathCoordinates]
,[Distance]
FROM Inserted


END

Logic Lab technologies
Email:balwant.mnd@gmail.com
Website:www.techlogiclab.com
Author: Maverick             
Posted Date: March 24, 2011     Points: 20   

Hello,

Can you tell the value of the distance column before 37.21

May be after the trigger is fired a funtion might called from applcation.

Just provide the previous value to make it clear.

Thanks,
Maverick

Thanks,
Maverick
Author: Pandian             
Posted Date: March 24, 2011     Points: 20   

Hi Balwant

How could you create same name for "Trigger" and "Table" in dbo schema ?

If not I then who, If not now then when
Author: Karthikeyan Anbarasan       [Moderator]      
Posted Date: March 24, 2011     Points: 20   

yes pandian you are right!!!! but his table name is Exit_Path and trigger name is Shortest_Exit_Path...

Thanks
Karthik
http://www.f5debug.net
Mark as Answer if the answer solves your issue!!!
Author: Pandian             
Posted Date: March 24, 2011     Points: 20   

Hi Karthik

I noticed that the same name "Shortest_Exit_Path" used for TRIGGER and TABLE being Inserted and owner name also default / dbo :)

CREATE TRIGGER [dbo].[Shortest_Exit_Path]

INSERT into Shortest_Exit_Path([ProjectId]

Cheers

If not I then who, If not now then when


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