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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Rollback for every insert and update

Author  Topic 

johnsonlim026
Starting Member

3 Posts

Posted - 2012-02-13 : 09:38:53
Hi,
I have a stored procedure which insert & update many many tables.
Every times after i execute for debug, i have to delete the data table by tables.This cause many time spended and tedious work.
I have find online there is 1 or 2 lines of code which can help u insert/update the tables but then immediately rollback so that we do not have to do so many delete.The line like BEGIN transanction and then something else. But i can't find the code.
Does anyone has any idea?
Help Please!!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-13 : 09:42:19
begin transaction <some tran id>
... your insert code
...your update code
select * from table--display inserted values

rollback tran <tranid>



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -