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
121 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now