SQL failed to execute the “ROLLBACK” command

55 pts.
Tags:
SQL
SQL Query
SQL Server
SQL Server Rollback
WAMP Stack
In the process of querying i made a mistake in an UPDATE statement which affected my "UNIT" field (all UNIT changed to 500). I used the ROLLBACK but dit not work. Please help

Software/Hardware used:
SQL in WAMP

Answer Wiki

Thanks. We'll let you know when a new response is added.

Before you can issue a rollback you have to explicitly issue the BEGIN TRANSACTION statement, like this.

<pre>BEGIN TRANSACTION

UPDATE YourTable
SET Unit = 500

ROLLBACK</pre>

If you don’t include the BEGIN TRANSACTION statement you can’t issue the ROLLBACK statement.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Okappaw
    Thank you for the answer, may be i did not do the execution well. I had the following error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRANSACTION UPDATE invoice SET Unit = 500 ROLLBACK' at line 1 when I typed the statements below BEGIN TRANSACTION UPDATE invoice SET Unit = 500 ROLLBACK; the table did not "rollback" NB: Table name: INVOICE fields :Item, Qty, Unit i am looking forward to hearing from you
    55 pointsBadges:
    report
  • carlosdl
    Okappaw, Mrdenny's answer applies to SQL Server only but it seems that you are using MySql. That is why it is so important to clearly specify the products you are using. On MySQL, each command must be ended with a semicolon, and OTOH "BEGIN TRANSACTION" is not a valid command on MySQL. Additionally, autocommit may be enabled in your database. If so, you can't rollback your transaction.
    69,175 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following