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
 General SQL Server Forums
 New to SQL Server Programming
 delete everything about a user

Author  Topic 

christina_rules
Starting Member

23 Posts

Posted - 2007-05-23 : 09:09:07
hey, i'm trying to delete everything record that is connected to a user i want to delete..however, i've been getting error due to the fact that the username also serves as foreign keys..is there anyway i can solve this?

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-23 : 09:12:18
While deleting Master-Details kind of records, always you will have to first delete all the dependent detail records for the given master record and then you can proceed to delete master record.

In your case also, you will have to delete all records which are dependent on give User name before deleting the user record itself.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

christina_rules
Starting Member

23 Posts

Posted - 2007-05-23 : 11:20:12
what about on delete cascade? i read articles online that seems to suggest it works but so far no luck..
Go to Top of Page

pvedi
Starting Member

6 Posts

Posted - 2007-05-23 : 11:29:36
You can change the Foreign Key to be cascade on "delete or set null."
Go to Top of Page
   

- Advertisement -