Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Role back transactions if found any error

Author  Topic 

feejaz
Yak Posting Veteran

68 Posts

Posted - 2008-12-26 : 02:26:21

Hello all,

I want to make sql script to execute the database in which I have alter the table and add the records to the tables, also create and alter the store procedures, Functions and views.
I need to role back all the addition and modification, if there is any error occur during executing the script.
I have tried to use like

Begin transaction
Go

All Store Procedures, Views ,Functions etc
GO

Commit transaction
GO

But when I executed it, it could not role back transactions.


Have any idea?

thanx

feejaz

Navi

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2008-12-26 : 04:02:34
RollBack Transaction Statement is missing in ur script

The Order is

Begin Transaction

IF any error occurs
RollBack Transaction


At the end
Commit Transaction


Jai Krishna
Go to Top of Page

feejaz
Yak Posting Veteran

68 Posts

Posted - 2008-12-26 : 05:25:54
T

Navi
Go to Top of Page

feejaz
Yak Posting Veteran

68 Posts

Posted - 2008-12-27 : 03:59:07
Thanx for reply,

Any example please.

regards,

feejaz

Navi
Go to Top of Page
   

- Advertisement -