Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
Create  PROCEDURE DeleteRecycleAssignmentGiven      
       
@Given_Id  int             
                
AS             
 SET NOCOUNT ON             
 SET XACT_ABORT ON              
             
 BEGIN TRAN          
         
         
 UPDATE    dbo.S_Assignment_Given_Master
 SET    S_Assignment_Given_Master.IsDelete='true'  
	WHERE  Given_Id = @Given_Id   

 UPDATE    dbo.S_Assignment_Given_Child
 SET    S_Assignment_Given_Master.IsDelete='true'  
	WHERE  Given_Id = @Given_Id   

 UPDATE    dbo.Batch_Assignment_Mst
 SET    S_Assignment_Given_Master.IsDelete='true'  
	WHERE  Given_Id = @Given_Id   

COMMIT


when i update.... Can this procdure make update in All 3 Table? this procdure right?
Posted
Updated 12-May-14 1:10am
v2
Comments
KaushalJB 12-May-14 7:15am    
Yes you can....

just write COMMIT TRAN
Thanks7872 12-May-14 7:16am    
Run this and check it whether it works as you expected or not? Why you posted this here?
Tejas Vaishnav 12-May-14 9:42am    
have you try to run this procedure? if so, then what was the output?

there will be nothing look like wrong in the above procedure, just try to execute it and check output is desired or not?

1 solution

The answer is: YES and NO. It depends of many factors:
1) Does tables have relationship between them (PK-FK)?
2) Does cascading updation is enabled: ON UPDATE CASCADE?

Please, refer these:
CREATE TABLE (Transact-SQL)[^]
Cascading Referential Integrity Constraints[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900