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 2005 Forums
 Transact-SQL (2005)
 Run procedure

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2007-02-13 : 12:59:31
Hello,

I have two tables: Documents and DocumentsRatings

Each record in DocumentRating as a FK named DocumentID which is the PK in Documents.

Sometimes I will need to reset the DocumentsRatings for a certain DocumentId. So I created a stored procedure named DeleteAllRatingsGivenDocumentId.

When I delete a document in Documents I will also need to delete all document ratings. Can I call DeleteAllRatingsGivenDocumentId from stored procedure DeleteDocument?

Or should I do this in a different way?

Thanks,
Miguel

X002548
Not Just a Number

15586 Posts

Posted - 2007-02-13 : 13:32:41
You could set the tables up to cascade the delete to the children

or a trigger

and yes a sproc can call a sproc

so many choices



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -