2014中使用事务语句时出现问题

2014中使用事务语句时出现问题

本文介绍了在SQL Server 2014中使用事务语句时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。最近我不得不在Sql Server中使用Update查询。下面提到的方式是在Transaction块中写一个更新查询的好习惯吗?;



-------

开始交易xyz -1



我的更新查询在这里执行-2



回滚交易xyz -3



提交交易xyz -4

-----------

所以最初我先执行2行,取决于我的结果是否正确,我执行了声明3或4.



现在我想问执行声明3或4后,我的交易将结束,并且与我的交易相关的任何类型的流程/线程仍然是活跃的,并且关于正确使用交易及其替代品的建议将非常感谢



预先感谢您的帮助。



我尝试过:



嗨。最近我不得不在Sql Server中使用Update查询。下面提到的方式是在Transaction块中写一个更新查询的好习惯吗?;



-------

开始交易xyz -1



我的更新查询在这里执行-2



回滚交易xyz -3



提交交易xyz -4

-----------

所以最初我先执行2行,取决于我的结果是否正确,我执行了声明3或4.



现在我想问执行声明3或4后,我的交易将结束,并且与我的交易相关的任何类型的流程/线程仍然是活跃的,并且关于正确使用交易及其替代品的建议将非常感激

Hi. Recently i had to use a Update query in Sql Server. Is below mentioned way of writing Update query within Transaction block a good practice?;

-------
Begin Transaction xyz -1

My Update query to execute here -2

Rollback transaction xyz -3

Commit transaction xyz -4
-----------
So initially I executed first 2 lines, depending upon whether my result was correct or not, I executed either statement 3 or 4.

Now i want to ask that after executing statement 3 or 4, will my transaction end and will any sort of process/thread related to my this transaction will still be active and also suggestions regardings proper usage of Transaction and its substitutes will be really appreciated

Thanks in advance for your help.

What I have tried:

Hi. Recently i had to use a Update query in Sql Server. Is below mentioned way of writing Update query within Transaction block a good practice?;

-------
Begin Transaction xyz -1

My Update query to execute here -2

Rollback transaction xyz -3

Commit transaction xyz -4
-----------
So initially I executed first 2 lines, depending upon whether my result was correct or not, I executed either statement 3 or 4.

Now i want to ask that after executing statement 3 or 4, will my transaction end and will any sort of process/thread related to my this transaction will still be active and also suggestions regardings proper usage of Transaction and its substitutes will be really appreciated

推荐答案


这篇关于在SQL Server 2014中使用事务语句时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-21 03:02