sqltransaction

SQL Server Sequence Gaps

风流意气都作罢 提交于 2019-12-31 02:04:54
问题 I have a SEQUENCE that I used to set the transaction folio of a table: CREATE SEQUENCE [Seq].[Folio] AS [bigint] START WITH 114090 INCREMENT BY 1 MINVALUE -9223372036854775808 MAXVALUE 9223372036854775807 CACHE Today just for curiousity I did a: SELECT folio FROM transactions ORDER BY folio DESC and what was the surprise that there are gaps, so there are missing folios in the table. Example: 898, 897, 894, 892, 890, 889 ... That means that something is happening. Just to give more information

SqlTransaction after catch transaction connection is null

怎甘沉沦 提交于 2019-12-31 00:58:30
问题 I have a loop where I call stored procedure with different parameter value. Next call cmd.ExecuteNonQuery(); I use transaction to save all or rollback, and checkBox2 - save always. I found one problem and I can't find solution. After first problem when catch block is fired transaction object loses its connection. t.connection is null! Everything is good but transaction object is without connection at start it has! try { while (!sr.EndOfStream) { strLine.Remove(0, strLine.Length); //c = sr

SqlClient.SqlTransaction vs System.Transactions

谁说我不能喝 提交于 2019-12-24 14:37:34
问题 We have some constant issues with MSDTC setting up, now considering replacing SystemTransactions with SqlTransactions . I am interested in differences of the above, and possible issues we might have doing that. 回答1: The article quoted and referenced by Massimiliano was 7 years old when referenced and therefore refers only to .NET 2.0 and SQL Server 2000 and 2005. However, I believe the salient points are still valid for later versions. I'm having trouble finding directly applicable commentary

Finally Clause in SQL Server Transaction? Something that will execute irrespective of success or failure?

一笑奈何 提交于 2019-12-23 17:26:13
问题 In SQL Server, is there something similar to finally clause in try..catch... block of c# ? I mean, I am using BEGIN TRAN, END TRAN, COMMIT TRAN, ROLLBACK TRAN etc in a SQL Server transaction and want a section or some set of actions that needs to fire irrespective of success or failure or transaction. Is there a solution for that? (similar to finally block on try/catch of OOPS languages). Thanks in advance 回答1: There isn't anything that will run "irrespective of success or failure" with 100%

TransactionScope/SqlTransaction timeout extension

做~自己de王妃 提交于 2019-12-23 11:54:40
问题 Is it possible to extend the timeout of a transaction (with SQL Server) once the transaction has started? 回答1: The timeout is "external" to SQL Server, so SQL Server can not affect it. So "no" unfortunately 回答2: I doubt it, but you could rollback and retry. 来源: https://stackoverflow.com/questions/4723944/transactionscope-sqltransaction-timeout-extension

how to manage nested transaction with try catch

[亡魂溺海] 提交于 2019-12-23 05:23:04
问题 --Drop Table Tab1 Begin Transaction TR1; Save Transaction TR1; Create Table Tab1(f1 decimal(10,0)); Begin Transaction TR2 Save Transaction TR2 insert into Tab1 values(1); Begin Transaction TR3; Save Transaction TR3; insert into Tab1 values(2); Begin Try insert into Tab1 values('OK'); Commit Transaction TR3; END TRY BEGIN Catch print 'catch' RollBack Transaction TR3; End Catch insert into Tab1 values(3); Commit Transaction TR2 insert into Tab1 values(4); Commit Transaction TR1; --Commit

JDBC Transaction control in Sybase

旧街凉风 提交于 2019-12-23 02:44:14
问题 Need help in JDBC transaction control mechanism in JAVA. Issue: There are certain stored procedures in our Sybase DB that needs to be run on Unchained mode. Since we are updating our data on two different databases (unfortunately, both Sybase) we need to be able to rollback all our previous transactions, if there is any failure. But running with Unchained Mode (Auto commit - on) is not helping us with the rollbacks as some of the SPs have already committed the transactions. Connection

SQL SERVER - Understanding how MIN(text) works

痞子三分冷 提交于 2019-12-19 12:27:16
问题 I'm doing a little digging and looking for a explanation on how SQL server evaluates MIN(Varchar) . I found this remark in BOL: MIN finds the lowest value in the collating sequence defined in the underlying database So if I have a table that has one row with the following values: Data AA AB AC Doing a SELECT MIN(DATA) would return back AA. I just want to understand the why behind this and understand the BOL a little better. Thanks! 回答1: It's determined by the collation (sort order). For most

Sharing transactions between connections

这一生的挚爱 提交于 2019-12-12 22:05:07
问题 I have a FileShare crawler (getting permissions and dropping them somewhere for later Audit). Currently it is starting multiple threads to crawl the same folder (to speed up the process). In C#, each SqlConnection object has its own SqlTransaction , initiated by the SqlConnection.BeginTransaction() call. Here is the pseudo code of the current solution: Get list of folders For each folder get list of sub-folders For each sub folder start a thread to collect file shares Each thread will save

SQL Server Broker Transaction Completed on Poison Message Exception

北慕城南 提交于 2019-12-11 18:08:49
问题 I am using SQL Server Broker in 2008 R2 in a C# application and am trying to handle the case where SQL Server has detected a poison message and has disabled the target queue. When this case occurs, an SqlException is thrown when I'm trying to receive a message. At that point, the SqlTransaction I'm using seems to no longer be committable. I'll use this tutorial to demonstrate along with my C# code. First use the T-SQL code from the tutorial to create the necessary service broker objects and