SQL Query Delete

I have a SQL job that runs every night at 10PM. It has three tasks. The first task runs a query against my Canada db populating a table called ToolsOnRent with Canada tools with a status of R.

The second task does the same thing for US.

The third task validates.

When the job ran on 8-11-15, it failed after the 1st task. So i re-ran the job after receiving the failure email. The job ran successfully.

However, when I got into the office this morning, i noticed that Canada rows were duplicated for any tools that has a Rent status on 8-11-15.

Below is a screenshot. I just chose a couple of the serial numbers i knew belong to tools that were rented by a Canadian store. The Canadian store numbers all begin with 07. The embedded screenshot also shows how the table is structured.

SQL Table that shows example of duplicated rows
How do I delete all of the duplicated rows for just the Canadian stores that begin with 07 for 8-11-15?
LVL 1
isamesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
They aren't duplicate rows. They have different values for some columns.
Anyway, if you want to delete the duplicate rows, which one should be kept and which one should be deleted?
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please see this article on how to decide on what Vitor indicates and to accordingly write the delete:
http://www.experts-exchange.com/articles/15139/SQL-Server-Delete-Duplicate-Rows-Solutions.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ste5anSenior DeveloperCommented:
And use an appropriate primary key and additional unique constraints..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.