Need utility for deleting rows

  • Thread starter Thread starter Chris Dunaway
  • Start date Start date
C

Chris Dunaway

In the course of developing my application, it inserts many test rows
into the test database. These are standard Orders with details and
other data. Now, I wish to delete these "dummy" orders, but because
of the relationships between the order, details, and other tables,
it's a tedious manual process.

I was wondering if anyone know of any "ready-made" utilities for
selecting a row in a table and deleting it along with any rows on
which it depends or depends on it. For example, if I provide an order
id, I want to delete that order, plus any details and any addresses,
contacts, etc. which are related to that order.

I can write a script to do this, but in an effort to save some time, I
thought I would check to see if anyone knows of any utilities that can
do this. Since this is a test database that is shared by other
developers, I cannot simply truncate the tables.

As I said, writing a script would take me time that I would rather not
expend unless I have to. That's why I am asking if anyone knows of a
utility or script that is available to do this.

Thanks for any assistance.

Chris
 
Chris,

I don't know of any tools, but if you have set up the relations
correctly in the database, you should be able to query the underlying schema
information and use that to dynamically create delete statements for related
records.
 
If you have correct relationships defined with cascading deletes, deleting a
parent should delete the children.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
 
Back
Top