|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Need utility for deleting rowsinto 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. -- Show quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "Chris Dunaway" <dunaw***@gmail.com> wrote in message news:1194027526.546170.113380@19g2000hsx.googlegroups.com... > 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 > If you have correct relationships defined with cascading deletes, deleting a
parent should delete the children. -- Show quote____________________________________ 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) ----------------------------------------------------------------------------------------------------------------------- "Chris Dunaway" <dunaw***@gmail.com> wrote in message news:1194027526.546170.113380@19g2000hsx.googlegroups.com... > 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 > I always just set up a simple stored procedure to do this.
Show quote "Chris Dunaway" <dunaw***@gmail.com> wrote in message news:1194027526.546170.113380@19g2000hsx.googlegroups.com... > 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 > |
|||||||||||||||||||||||