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.
233 questions
1
vote
2 answers

How do reduce transaction log growth for batched nvarchar(max) updates

Our app needs to add large amounts of text to SQL Server 2005 database (up to 1 GB for a single record). For performance reasons, this is done in chunks, by making a stored procedure call for each chunk (say, usp_AddChunk). usp_AddChunk does not…
Chris
  • 3,664
  • 6
  • 34
  • 44
1
vote
1 answer

JDBC transaction, execution order of sql statements

I have following JDBC code: Connection conn = connectUserDataSource(); // Setting auto commit to false to execute all queries as part of transaction conn.setAutoCommit(false); PreparedStatement deletePreparedStatement =…
Ihor M.
  • 2,728
  • 3
  • 44
  • 70
1
vote
1 answer

Applying MySQL transactions to my shopping cart checkout process

I have this online shop that I built a while ago and I've been using LOCK TABLES on the product stock tables to make sure stock doesn't go below 0 or isn't update properly. Lately there's been a lot of traffic and lots of operations (some other LOCK…
teomor
  • 144
  • 1
  • 8
1
vote
2 answers

SQL Database is locking when triggers are used

I've an issue with deadlock.. I'm trying to provide sql dependency on updates to my database. I do this by creating a trigger on a series of tables. When tables are modified, I increment a integer in a secondary table eg. [dbo].[counters]. I then…
savagepanda
  • 857
  • 12
  • 25
1
vote
1 answer

transaction in program vs transaction in database

i'm new programmer all i know is has 2 way to sql transaction control . But i want to know is 1.1 when should be use transaction in program and when should be use transaction in database. 1.2 which is better (now i think sql transaction in…
1
vote
1 answer

Error when using transaction

Possible Duplicate: ExecuteNonQuery requires the command to have a transaction error in my code strSQL = "insert into............"; SqlTransaction objSqlTransaction = Master.objSqlDbComm.SqlConnectionObject.BeginTransaction(); try { …
lax
  • 518
  • 2
  • 11
  • 26
1
vote
1 answer

.NET webservice timeout - abandon work

I have a Winforms application that calls a webservice method The webservice method starts a long running transaction (unfortunately there are lots of little commands as opposed to one long running one.) As far as I can see if the webservice call…
AJM
  • 32,054
  • 48
  • 155
  • 243
1
vote
2 answers

SqlClient.SqlTransaction vs System.Transactions

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
vote
1 answer

Processing Thousands of SqlCommands using a SqlTransaction Causes Memory Exception

I've written a custom replication function in a standard C# windows forms app with a SQL Server 2008 Express database. It basically pulls down a set of sql statements that need to be executed against a subscriber database. On a complete refresh this…
Gary
  • 742
  • 8
  • 20
0
votes
1 answer

SQL Transactions using PHP failure

This is my code. I know this should be easy, but somehow, SQL returns a parse error. Please Help. $link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD,DB_DATABASE); if(mysqli_connect_errno()) { die('SQL ERROR : ' .…
Anudeep Bulla
  • 8,318
  • 4
  • 22
  • 29
0
votes
4 answers

Can any one tell whats' wrong in my transaction

Hi all i have written the following transaction to insert data but when i am getting an exception only the data which got the exception not inserting to db the remaining all are inserting This is what i wrote public bool addWhole(SqlTransaction…
Ramakrishna
  • 203
  • 1
  • 5
  • 13
0
votes
4 answers

(SQL-T-SQL) Select Command to Have only certain values?

Here is my table…
Martin Gemme
  • 345
  • 3
  • 17
0
votes
0 answers

Can you have a Select in the middle of an ADO transaction

I have some code that goes like this: SqlTransaction trans = conn.BeginTransaction("MyTransfer"); cmdStep1.ExecuteScalar(); cmdStep2.ExecuteScalar(); cmdStep3.ExecuteScalar(); QueryTheDatabaseForSomeData() // here it calls another method that…
0
votes
0 answers

An EF Core transaction on the other DbContext isn't disposed after the original one is when using UseTransaction

Here's an interesting behavior I ran into the other day. I'm using EF Core's UseTransaction method to share a transaction with another DbContext. The problem I ran into was that the other context would keep the transaction even after the original…
Michal Diviš
  • 2,008
  • 12
  • 19
0
votes
1 answer

SQL Server deadlock on read uncommitted isolation level

I get error message "Transaction (Process ID 60) was deadlocked on lock resources with another process ...". I have two simple queries like: Query 1: BEGIN try SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN tran update…