Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Searching numerous tables and deleting from them

Author  Topic 

al_gsy
Starting Member

6 Posts

Posted - 2006-01-27 : 11:17:23
Hi,

I've got a database with numerous tables that holds id codes under various titles e.g. code, parent_code etc.

I don't really want to write over 30 seperate delete statements, so I was wondering if I would be able to write a cursor to search through the tables and delete from them if the code exists in it?

The only other catch is that some of the tables have primary/foreign key constraint, so I think i'd also need to drop and recreate the constraints as the cursor runs.

Is this a sensible option? Or should I just bite the bullet and write the delete statements?

Cheers,

Al

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2006-01-27 : 12:28:44
I would bite the bullet as you may have trouble re-applying your contraints if you delete in this way.
Go to Top of Page
   

- Advertisement -