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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

746 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

13 Experts available now in Live!

Get 1:1 Help Now