Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-03-24
3
Medium Priority
?
275 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
[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
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1200 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 800 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

730 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