How can delete data from maltiple table?

Posted by Bageshkumarbagi under Sql Server on 7/4/2013 | Points: 10 | Views : 786 | Status : [Member] | Replies : 2
Hi,

I have more than 5 table. Book table have bookid that is primary key and all other (more than 5 table ) have book id as Foreign key . I want to supply particulr bookid and want to delete all details from all file. can any one help me . please write store procuder for that. Thanks in advance....

Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied



Responses

Posted by: Pandians on: 7/4/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Enable "ON DELETE CASCADE" action on your all Foreign Key tables.
So, Delete action will be taken place automatically when you DELETE on Parent Table!

(Or)

DELETE respective data from child table(s) first and then ParentTable using Procedure(If Needed)

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Bageshkumarbagi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Neeraaj.Sharma on: 7/5/2013 [Member] Starter | Points: 25

Up
0
Down
just to add Pandians Ans visit this:


http://www.tutorialsqlserver.com/Create/Foreign-Key-In-Sql-Server.htm








Bageshkumarbagi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response