Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6055071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:13:24+00:00 2026-05-23T08:13:24+00:00

Is using Commit in a transaction enough or I should use rollback too. tabel1

  • 0

Is using Commit in a transaction enough or I should use rollback too.

tabel1
  name   nvarchar(10)
  family nvarchar(20)

table 2 
    name nvarchar(10)
    family nvarchar(20) not null

begin transaction
insert into table2 (name) values('john')
insert into table1 (name,family) values('Joe','Lando')
commit transaction

as you see the first statement has error. should I use rollback somewhere?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:13:25+00:00Added an answer on May 23, 2026 at 8:13 am

    You can skip ROLLBACK if you use SET XACT_ABORT ON (SQL Server 2000 link)

    SET XACT_ABORT ON
    begin transaction
    insert into table2 (name) values('john')
    insert into table1 (name,family) values('Joe','Lando')
    commit transaction
    

    From the link:

    When SET XACT_ABORT is ON, if a Transact-SQL statement raises a run-time error, the entire transaction is terminated and rolled back.

    Now, if you don’t use it you need rollback. Or close your connection.

    One useful side effect of SET XACT_ABORT ON is that after a client CommandTimeout event, locks are released and the transactions rolled back. Otherwise, it doesn’t happen until the connection is hard removed from SQL Server: it can stay open because of pooling.

    Your bible should be “Error Handling in SQL 2000 – a Background” by Erland Sommarskog: read it. And on SO: Do I really need to use "SET XACT_ABORT ON"?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say a stored procedure on MSSQL Server uses an SQL transaction using BEGIN TRANSACTION/COMMIT
I saw few examples over internet of Hibernate using transaction.commit() for select statements. Below
We are planning NOT to use MSDTC for transaction managment in SSIS and instead
I am using Sping.Net 1.3.1 and Nhibernate 3.0. I use Spring's Transaction Interceptor in
i am using cruise control to automate the svn commit process. but the execution
I am using: set constraints all deferred; (lots of deletes and inserts) commit; This
We are using Subversion. We would like to 1. search across all commit messages
How can I stage and commit all files, including newly added files, using a
Using PyObjC , you can use Python to write Cocoa applications for OS X.
In my C# code I am using TransactionScope because I was told not to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.