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
 Statement to delete all dependencies data.

Author  Topic 

RichardBone
Starting Member

29 Posts

Posted - 2008-02-06 : 11:27:01
Is there a SQL statement that will delete the primary key data and data in the other tables that depend on that primary key?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-06 : 12:13:51
You should specify this while defining the foreign key in other tables. the clause used is ON DELETE CASCADE. this will ensure removal of referrenced records when primary key is deleted.
Go to Top of Page

RichardBone
Starting Member

29 Posts

Posted - 2008-02-06 : 12:35:15
Can I change it now manually?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-06 : 13:33:18
you can change it by ALTER CONSTRAINT statement
Go to Top of Page
   

- Advertisement -