Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Duplicate entries while inserting into a table.

Author  Topic 

iak1988
Starting Member

1 Post

Posted - 2012-05-03 : 13:17:44
I definitely need some help to resolve this head scratching issue of mine.

Issue In application, a report called 'Daily Exception Report' used to display exceptions of ISA. Here we are having duplicate entries(exactly two identical rows in the report) .

Technical details.

The exceptions report will be displayed with the data available in a table called 'ExceptionFirstReported' which has duplicate entries. Below Insert statement in the stored procedure usp_Refresh_Daily_Exception_Report is used to insert the row in the table.

Insert into ExceptionFirstReported(InvestorReference,ExceptionReason,First_Reported_Date,RelativeRef)

Select InvestorReference,ExceptionReason,Dateupdated,RelatedInvRef From(
Select * from
DailyExceptionReport As DER Where not Exists
(select ExcepRptd.InvestorReference from ExceptionFirstReported As ExcepRptd
where DER.InvestorReference = ExcepRptd.InvestorReference And
DER.ExceptionReason = ExcepRptd.ExceptionReason And
DER.RelatedInvRef = ExcepRptd.RelativeRef)) As CI join
currentISAs on CI.InvestorReference = Status_Inv_Ref
After analysing, we think there will not be any duplicate enteries can be inserted through the insert statement at two different instance, as there will not be a chance that more than a row has identical Investor reference, ExceptionReason and RelatedInvRef. However we are having duplicate enteries. This is the only one insert statement used to insert the rows into the table. And the tables DailyExceptionReport and currentISAs hasn't contain any duplicates...

Any frnds know the possible reason behind this strange behaviour of the SQL server 2005

Thnks in advance frnds

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-03 : 16:18:01
check if query is executed only once from application (you can use profiler trace for detecting this)

Also see if there's any insert trigger present on table ExceptionFirstReported

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -