Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Transaction syntax
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Transaction syntax
Miscellaneous
Thread ID:
00686750
Message ID:
00686750
Views:
83
Im trying to find the best way to run transactions with T-SQL. This is how im doing it..
begin transaction

declare @err1 int, @err2 int
/* Add a record to students */
insert into students (studentID, lastname, firstname, middleini, ...)  values (@studentid, @lastname, @firstname, ...)
set err1 = @@error

/* Log the move */
if @logmove = 1
  insert into movelog (studentID, hallfrom, ...) values (@studentID, 'NEW', ...)
set @err2 = @@error

if @err1 = 0 and @err2 = 0
begin
  commit transaction
    set @return = 'Move successfull'
end
else
  begin
     rollback transaction
     set @return = 'Unable to move student out. The transaction did not complete.'
 end
Im just wondering if there is an eaiser way to accomplish this?

TIA
Eric Stephani
Next
Reply
Map
View

Click here to load this message in the networking platform