Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How Transaction fails?
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01537235
Message ID:
01537246
Vues:
36
>>
>>begin transaction
>>  
>>   update Employee set EmpNo = 'Test10' where EmpNo = 'Test32'
>>commit transaction   
>>   update Salaries set EmpNo = 'Test10' where EmpNo = 'Test32'
>>
>
>Yes, this does work but it does not make sense to me. How come SQL Server allows the first update to work and change the value in the parent table and not throw an exception? In other words, even if you comment the second UDPATE, the first one does not fail. Then the Constraint does not work, does it?

You're right, it will not work. I was a bit surprised it worked until I remembered that I already updated EmpNo in the Salaries table with NULL with my previous update. And also noticed that I have 1 and 0 for rows affected.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform