Solved

Need Qry Syntax Help - Need to delete two records that are exactly the same

Posted on 2007-03-24
3
236 Views
Last Modified: 2010-03-19
I accidentally inserted two records that are exactly the same into a MS SQL (2005) table.  I can't delete them using the following qry:

Delete from Competitors where CompetitorID=66 and SeasonID=12 and EventID=0 and RunID=6

When I run the qry, it says 0 rows affected.  The only way I know how to fix this is truncate the table and then reinsert the data.  Is there another way, because there is no way I want to risk the data.

Thanks in advance!

Regards,
Eric
0
Comment
Question by:indy500fan
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 300 total points
ID: 18784981
>Delete from Competitors where CompetitorID=66 and SeasonID=12 and >EventID=0 and RunID=6
>When I run the qry, it says 0 rows affected.
then, your where clause is not correct.

can you please show the query that returns the data of the 2 rows (SELECT)?
I would use the following technique to delete a single row (even if there are several rows):
SET ROWCOUNT 1
DELETE Competitors  WHERE ...
SET ROWCOUNT 0
0
 
LVL 10

Assisted Solution

by:lahousden
lahousden earned 200 total points
ID: 18784988
If you are sure that these are the identifying values for these columns for the rows in question then it looks like you don't have the problem you think you have.  Change the "Delete" to a "Select * " in your SQL statement and see whether in fact you still have the troublesome rows in your table, i.e.

Select * from Competitors where CompetitorID=66 and SeasonID=12 and EventID=0 and RunID=6
0
 

Author Comment

by:indy500fan
ID: 18785143
angellll,
Well after trying to duplicate, I can't.
Thanks,
Eric
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

864 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

21 Experts available now in Live!

Get 1:1 Help Now