Solved

I have an update trigger that grabs the qty value from inserted,  this value is always double what was inserted by the end user?

Posted on 2014-10-06
4
127 Views
Last Modified: 2014-11-05
The update trigger grabs one field, the qty field and inserts into a table created by us.  The value is always double what was entered.  Please help.
0
Comment
Question by:spoye
  • 2
  • 2
4 Comments
 

Author Comment

by:spoye
ID: 40364117
here is a the insert?


                  

if (Update(qty_ordered))
Begin            
             
insert into PUt_qtychange (conum,coline,udpatedby,qtyorderd,price)

select     item,
                     co_num,
                     co_line,
                   updatedby,
               qty_ordered,
               price
      from      inserted

end
0
 
LVL 17

Expert Comment

by:OriNetworks
ID: 40364518
Are you sure you are only inserting one line? Watch out for where it may be inserting multiple lines or where that may happen in the future.
0
 

Author Comment

by:spoye
ID: 40364736
I only update the qty and then checked the table only one line is inserted.
0
 
LVL 17

Accepted Solution

by:
OriNetworks earned 500 total points
ID: 40386559
What exactly are you trying to accomplish with this trigger and what is the name of the table that this trigger is on?

If this trigger is on table PUt_qtychange  and you are also telling it to insert to PUt_qtychange, then yes, of course your records will be doubled because for each insert you are telling the trigger to insert again.

Additionally, you can use SQL Profiler to see exactly what values are being passed to update the table.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question