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
132 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

734 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