Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read and write in a transaction

Status
Not open for further replies.

lookie

MIS
Sep 6, 2001
2
US
please look this code:

begin tran
insert table1 ....
update table1 ....
select * from table1
rollback tran

the result of select is right.but can I always believe this
result?
you know when issue the select, the data still not stored into the database. so from where the select get the right data? can this data always right?
thanks a lot.
 
within a transaction sql server has a before and after image of the data. I believe that in your example the select would show the results of the insert and update. If you did another select after the rollback the insert and update actions would be gone. So what do you mean by the result of the select is right? Does it show the insert and update? After your rollback all the changes in the transaction will disappear. Ruairi
ruairi@logsoftware.com
Experienced with:

VB6, SQL Server, QBASIC, C(unix), MS Office VBA solutions

ALSO: Machine Control/Automation using GE and Omron PLC's and HMI(human machine interface) for industrial applications
 
thanks for you answer,but sometime ,I want to use the SELECT's result in a tran,such as:
begin tran
insert table1 ....
update table1 ....
select @@identity from table1
...
update table2 set col1=@@identity
...
rollback tran

so though the tran rollback.the select is still important for my tran.
I only want to sure if I can believe all select's result in a tran.
thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top