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
 SQL Server Development (2000)
 Cascade Delete

Author  Topic 

jesus4u
Posting Yak Master

204 Posts

Posted - 2002-09-30 : 13:21:42
Is there a way in a trigger when I delete a user from the USers table that it deletes any related records in the Orders table for that user?

Thanks

chadmat
The Chadinator

1974 Posts

Posted - 2002-09-30 : 13:39:16
Sure is. That is the way you had to handle cascading prior to SQL 2000.

Cascading is now built in to SQL 2000, so if you are using 2000, you might want to look into that.

If not just delete from the Orders table based on a join between the deleted table, and Orders.

-Chad



Go to Top of Page

jesus4u
Posting Yak Master

204 Posts

Posted - 2002-09-30 : 13:40:47
quote:

Cascading is now built in to SQL 2000, so if you are using 2000, you might want to look into that.



I can not find that feature to save my life! Where would I look?!

Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2002-09-30 : 13:53:28
Books Online.

Topic:
Cascading Referential Integrity Constraints

-Chad

Go to Top of Page

jesus4u
Posting Yak Master

204 Posts

Posted - 2002-09-30 : 13:55:12
but isn't that just for triggers?

Go to Top of Page

jesus4u
Posting Yak Master

204 Posts

Posted - 2002-09-30 : 14:14:11
Sorry to bother you but I am confused!

In BOL it says that I am supposed to have the cascade delete options under the Relationships tab. I DON'T. According to this thread I am supposed to as well.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=2916

PLease look at my database picture with the relationship tabe opened and can you tell me where I am wrong?



Thanks



Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-09-30 : 14:42:30
Is your database set for SQL 7.0 compatibility? (or earlier?) If it's not set for SQL 2000/v8.0 compatibility then you won't be able to use CASCADE.

Go to Top of Page

jesus4u
Posting Yak Master

204 Posts

Posted - 2002-09-30 : 14:44:12
quote:

Is your database set for SQL 7.0 compatibility? (or earlier?) If it's not set for SQL 2000/v8.0 compatibility then you won't be able to use CASCADE.





How can I check this?

Go to Top of Page

jesus4u
Posting Yak Master

204 Posts

Posted - 2002-09-30 : 14:46:36
yes thank you I got it now.

Go to Top of Page
   

- Advertisement -