[dba-SQLServer] Cancel INSERT?

Francisco Tapia fhtapia at gmail.com
Mon Mar 6 13:05:26 CST 2006


that would be

begin transaction t1

IF @@ERROR <> 0
   BEGIN
           ROLLBACK TRANSACTION t1
  END
ELSE
  BEGIN
       COMMIT TRANSACTION t1
  END


How else would you know which transaction you'd want to uncommit?
Additionally you can always give your user a gui to review the data and
perform a DELETE FROM myTable where ID = @ID

On 3/6/06, Susan Harkins <harkinsss at bellsouth.net> wrote:
>
> I was really thinking of something more automated like an .Undo. :)
>
> Susan H.
>
> @@ Identity may problematic as this variable will contain the last insert
> from anybody, using Scope_Identity() may be a better solution as it gives
> you the last id used in your session.  If however the insert has ran and
> now
> you want to lookup what you did because you need to roll it back you can
> do
> it manually with software from quest software or idera
>
>
> >
> > > I know I can wrap INSERT in a transaction. Barring a transaction
> > > that
> > keeps
> > > the action from being committed, is there anyway to undo an INSERT
> > action
> > > that's been committed?
>
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>


--
-Francisco
http://pcthis.blogspot.com |PC news with out the jargon!
http://sqlthis.blogspot.com | Tsql and More...



More information about the dba-SQLServer mailing list