Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger deletes...

Status
Not open for further replies.

Johnny42

Technical User
Jul 13, 2004
127
CA
can I delete all records from several tables at once ?
The tables are not related
 
You may consider a Stored Procedure.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
DELETE FROM table1, table2, table3; ?

RESULTS IN ...ERROR "Specify the table containing the records you wantto delete...:(
 
You need to do a delete per table

If you need to code this on VB or another language then you may wish to consider the use of a SP as PHV mentioned so that your VB code only executes one SQL statement, and the deletes are all done on the server side.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
thanks fredericofonseca ,
I was just gonna loop the tables in VBA...
I would not know were to start as a SP :(


Thanks...:)
 
If you don't have something already you will probably need to manage your databases.


As for stored procedures, please search these forums and and for stored procedures and you will find plenty of information and samples. Then if you have questions please come back to us with some code.


A small sample.

create procedure dbo.deletetables as
delete from mytbl where myfld not = 9999
go
delete from mytbl2 where myfld2 not = 9999
go;

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Thanks for the info...will give it a try and follow up...:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top