Questions tagged [sqltransaction]

An SQL-transaction is a unit of work that is performed against a database. Transactions are units or sequences of work accomplished in a logical order. Executing SQL-statements in Transactions, can ensure data integrity and handle database errors.

An SQL-transaction is a unit of work that is performed against a database. Transactions are units or sequences of work accomplished in a logical order.

A transaction is the propagation of one or more changes to the database. For example, creating, updating, or deleting a record from the table. Transactions are used to ensure data integrity and to handle database errors, by collecting SQL queries into a group and executing all of them together, as one unit of work.

Properties of Transactions: Transactions have the following four standard properties, usually referred to by the acronym ACID:

  • Atomicity: ensures that all operations within the work unit are completed successfully; otherwise, the transaction is aborted at the point of failure, and previous operations are rolled back to their former state.
  • Consistency: ensures that the database properly changes states upon a successfully committed transaction.
  • Isolation: enables transactions to operate independently of and transparent to each other.
  • Durability: ensures that the result or effect of a committed transaction persists in case of a system failure.
214 questions
46
votes
7 answers

Executing a stored procedure inside BEGIN/END TRANSACTION

If I create a Stored Procedure in SQL and call it (EXEC spStoredProcedure) within the BEGIN/END TRANSACTION, does this other stored procedure also fall into the transaction? I didn't know if it worked like try/catches in C#.
Miles
  • 5,164
  • 17
  • 57
  • 84
24
votes
3 answers

SQL SERVER - Understanding how MIN(text) works

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…
tmercer
  • 347
  • 1
  • 3
  • 5
21
votes
3 answers

The transaction operation cannot be performed because there are pending requests working

background I have some code which opens a sql connection, begins a transaction and performs some operations on the DB. This code creates an object from the DB (dequeue), gets some values and saves it back. The whole operation needs to take place in…
Jay
  • 1,885
  • 5
  • 19
  • 39
21
votes
6 answers

how to use sqltransaction in c#

I am using following code to execute two commands at once. I used sqltransaction to assure either all command get executed or rolled back.When I run my program without "transaction" it run properly but when I use "transaction" with them they show…
Sonu_Orai
  • 347
  • 2
  • 7
  • 17
15
votes
2 answers

The configured execution strategy 'SqlAzureExecutionStrategy' does not support user initiated transactions

I am using the latest v6 of Entity Framework along with a UnitOfWork pattern. This has been fine on a server for the past few years. I want to move to azure hosting and use SQLAzure, so started to migrate the app. However I have had a number of…
leen3o
  • 8,636
  • 22
  • 72
  • 117
15
votes
1 answer

What is the scope of XACT_ABORT

What is the scope of a SET XACT_ABORT statement in SQL Server 2005? i.e.:begin-end block, procedure or trigger, connection, database, server?
14
votes
3 answers

Do not update row in ResultSet if data has changed

we are extracting data from various database types (Oracle, MySQL, SQL-Server, ...). Once it is successfully written to a file we want to mark it as transmitted, so we update a specific column. Our problem is, that a user has the possibility to…
Moh-Aw
  • 2,836
  • 2
  • 26
  • 43
9
votes
3 answers

Does SqlTransaction need to have Dispose called?

Do I need to call dispose in the finally block for SqlTransaction? Pretend the developer didnt use USING anywhere, and just try/catch. SqlTransaction sqlTrans = con.BeginTransaction(); try { //Do Work sqlTrans.Commit() } catch (Exception ex) …
Mike Flynn
  • 21,905
  • 50
  • 167
  • 308
8
votes
1 answer

Transaction error when Django REST Framework raises an error on purpose

I have updated a project using Django REST Framework from a 2.x version to the last stable version (3.1.3). After fixing some deprecated uses in my serializers, I ran python manage.py test to make sure nothing have been broken. Everything works fine…
Maxime Lorant
  • 28,973
  • 16
  • 79
  • 93
8
votes
2 answers

transactions and symfony2 entity manager

Is there a way to manually specify transactions in symfony2 with the entity manager (doctrine), or perhaps a natural way of accomplishing in a single transaction what I am doing below in two? // creating screen object... //Creating user object... …
Matt Welander
  • 7,437
  • 20
  • 84
  • 129
6
votes
2 answers

SqlTransaction after catch transaction connection is null

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…
pdusp
  • 91
  • 1
  • 4
6
votes
2 answers

How does Npgsql handle failed transactions?

In an ASP.NET application (C#) we are using Postgres as backend and Npgsql as data provider. A couple of days ago we had a serious problem with loss of data. I investigated in code and found code like this: var transaction =…
paolo_tn
  • 85
  • 5
6
votes
1 answer

SqlTransaction to support multiple SqlConnections

So I have multiple SqlConnections that I want to all be used in one SqlTransaction. I know that I could use just one connection, but ultimately in each connection there is a good amount of newly declared and useless (after the connection is done)…
Ian Best
  • 450
  • 1
  • 11
  • 23
5
votes
2 answers

SQL Server deadlock when only inserting new rows without performing any selects

I am seeing constant deadlocks in my app, even though it performs no select statements, no delete statements, and no update statements. It is only inserting completely new data. TL;DR: It seems to be related to the foreign key. If I remove that then…
Peter Morris
  • 13,426
  • 8
  • 61
  • 112
5
votes
1 answer

How to achieve consistent read across multiple SELECT using AWS RDS DataService (Aurora Serverless)

I'm not sure how to achieve consistent read across multiple SELECT queries. I need to run several SELECT queries and to make sure that between them, no UPDATE, DELETE or CREATE has altered the overall consistency. The best case for me would be…
1
2 3
14 15