Forum Moderators: open

Message Too Old, No Replies

How can i erase a data from 3 tables f

delete

         

justify

12:44 pm on Sep 11, 2003 (gmt 0)

10+ Year Member



Hi, EveryBody
I am using SQL Server 2000 database. I want to erase a data from mydatabase.
There is no problem for earsing one table like this (SQL = "DELETE UYDULAR WHERE UYDU_ID= " & id )
but i want to erase 3 tables that is relations. How can i do like this Can anybody advice to me?

txbakers

1:27 pm on Sep 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



SQL server has cascading deletes I beleieve. If you set up the tables so that they will check for referential integrity (like Access does), if you delete a key in one table, it will delete down the path.

IMHO though it's better to write the three delete statements so you can control what is being deleted.

mattur

2:26 pm on Sep 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep, in SQL Server you can have triggers for table events (e.g. delete, update, insert) to do cascading deletes etc. Note that if you enforce referential integrity you may run into problems because (I think) constraints are checked before triggers are fired.

As tx says, it may be easier to do individual deletes from your pages, or put the lot into a stored procedure anmd just call that. HTH.

ship2k

10:46 am on Oct 9, 2003 (gmt 0)

10+ Year Member



What's problem? "Delete * from Table1" or "Delete from Table1"? and other again if not cascading restriction?