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

How to use SQL Profiler Trace File with Dead Lock Events?

I am quite new to using sql profiler. I have a scenario in my application which runs on sql back end where i keep getting dead locks at the same place. I am able to reproduce it very easily. Using the link SQL Profiler Steps I was able to get a sql…
Vinod
  • 31,933
  • 35
  • 96
  • 119
1
vote
1 answer

How many transactions were started during the execution of the request?

I have a transaction. The code is set implicit_transactions on select getdate() begin transaction begin transaction select * from price p1, product p2 where p1.product_id = p2.product_id rollback delete from PRODUCT where product_id = 100871 …
George L
  • 13
  • 3
1
vote
3 answers

SqlTransaction and nested transactions

Is it possible to create nested transactions with a the SqlTransaction class? If so, what are the rules/limitations that I need to be aware of?
Jonathan Allen
  • 68,373
  • 70
  • 259
  • 447
1
vote
2 answers

Why is failed transaction not rolling back with TransactionScope?

What I'm trying to achieve is: I'm calling stored procedures from 2 different databases. SP's have a simple insert entry in a table. There is no problem if both the transactions are successful, But when I tried to throw an exception in the 2nd DB SP…
Code Wines
  • 241
  • 1
  • 11
1
vote
0 answers

Using DELETE with OUTPUT INTO clause not behaving atomic with SqlTransaction

As far as I read, this statement is atomic. Either both will fail or both will succeed: DELETE FROM TABLE1 OUTPUT DELETED.* INTO TABLE2 WHERE I have these statements executed through a stored procedure. When I execute said stored…
Amit
  • 11
  • 1
1
vote
1 answer

Transaction rollback VS Delete Records

Looking for some insights on using Transaction or Delete queries when the subsequent request fails. In brief, in my application, I'm inserting into two tables by calling two stored procedures and the inserted data would be uploaded into two REST…
S.Siva
  • 1,901
  • 4
  • 17
  • 22
1
vote
1 answer

Need assistance with SQL transaction to condense data in a database

I am trying to condense data in a database table which contains several instances of unique records with various column data. I want to select the highest occurring value for each column for each particular unique record But my SQL transaction…
JJCSZK
  • 11
  • 1
1
vote
0 answers

SqlTransaction skipping query instead of rollback

To manage our database changes I'm writing a simple C# program which will loop over an XML file and apply different statements. XML example: {{query}}
1
vote
1 answer

Best way to combine Insert, Update and Delete transaction in SQL Server 2008?

I have login process for my application that should run three different transactions if user successfully passed the authentication. Here is example of my current code:
espresso_coffee
  • 5,980
  • 11
  • 83
  • 193
1
vote
2 answers

Safely move/archive Rows in SQL Server

I have this SQL-script/sp BEGIN TRAN BEGIN TRY INSERT INTO TblDest SELECT * FROM TblSource DELETE FROM TblSource COMMIT TRAN END TRY BEGIN CATCH ROLLBACK TRAN END CATCH It moves all rows in…
Cowborg
  • 2,645
  • 3
  • 34
  • 51
1
vote
0 answers

Stuff function and how to order the stuff string order

I'm trying to stuff the Distinct Column values in the table based on grouping on particular columns, I'm able to stuff the distinct values of the column in to single String but the order of the string is not correct when I compare the result that…
Raj K
  • 458
  • 2
  • 7
  • 22
1
vote
1 answer

SQLTransaction: Retreive Inserted Identities In Scope

Am I able to use the OUTPUT inserted.identity value obtained after an insert during an SQL transaction (or does that even return a value)? Here's pseudo-code to explain the situation Begin SQLTransaction (Using .NET SQLTransaction) - Insert into…
1
vote
1 answer

MSSQL , How to let row updated only once

I have an table which has pre create rows. like ID BilNo Field1 Field2 55 NULL blabldd blalala 56 48989 blalala blalala For Example record 56 cannot be updated , becase of BilNo is not null. Now I have an two process(Query) or more than two…
Kevin yudo
  • 233
  • 4
  • 15
1
vote
1 answer

SQL: Merging similar rows while comparing versions

my dilemma looks like this: FileName Version Type Doc_Number Owner Request Date 1. ECN 0001 3 ECN NULL NULL NULL NULL 2. ECN 0001 1 NULL NULL NULL NULL …
Jsaville
  • 11
  • 1
1
vote
0 answers

C# Why SqlCommand constructor has both SqlConnection and SqlTransaction?

While SqlTransaction has a Connection property, why does SqlCommand have a constructor with both SqlConnection and SqlTransaction?
Jalil
  • 13
  • 2