C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Cascading deletes using trigger


Posted Date: 18 Sep 2008    Resource Type: Code Snippets    Category: SQL

Posted By: mohammad arshad       Member Level: Silver
Rating:     Points: 5



here we wish to implement that whenever an item is deleted all the things related to it in the database also gets deleted.Here we have a list of items a shop stocks and sells, as well as a stock transaction table which contains a list of purchases and sales for each stock item


CREATE TRIGGER stock_cascade_delete
ON Stock
FOR DELETE
AS
DECLARE @StockCodeToDelete int
SELECT @StockCodeToDelete = Stock_Code
FROM Deleted

DELETE FROM Stock_Transactions
WHERE Stock_Code = @StockCodeToDelete






Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Cascading deletes using trigger  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to write a Function in SQL Server
Previous Resource: INITCAP Function in SQL Server
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use