Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How Transaction fails?
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01537235
Message ID:
01537246
Views:
33
>>
>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform