Showing posts with label customerset. Show all posts
Showing posts with label customerset. Show all posts

Friday, February 10, 2012

Begin and Rollback in SQL Server 2005 Express

Does SQL Server 2005 Express support rollbacks? For example:

BEGIN;

UPDATE Customer
SET LastName = 'Jones';

ROLLBACK;

The ROLLBACK will undo/reverse the changes made by the UPDATE befor a COMMIT is executed.

Yeah, SQL server 2005 express supports transactions, I have used them on some of my projects.

Maybe your code should begin with

BEGIN TRANSACTION

|||

Thanks. I'll give that a try. I'm moving from the PostgreSQL sql syntax to MS SQL Server sql syntax. In PostgreSQL, I can give the command:

BEGIN;
...
COMMIT;

to complete the transaction. I guess in MS SQL Server the syntax needs to include 'BEGIN TRANSACTION'. Thanks again for the help.

|||

A good practice is to use Try..CATCH statements with transactions. Check here

http://technet.microsoft.com/en-us/library/ms175976.aspx

|||

Thanks for the TRY CATCH suggestion!