|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Most basic transaction?Hello
I was wondering if you could show me the most basic transaction in code? And rollback if error :) I suggest you read these articles by Erland Sommarskog:
http://www.sommarskog.se/error-handling-I.html http://www.sommarskog.se/error-handling-II.html There's more to know than you might expect. ML --- http://milambda.blogspot.com/ Hi, Lasse
See this excellent article by Erland Sommarskog, SQL Server MVP: http://www.sommarskog.se/error-handling-II.html#firstexample Razvan Go read the stuff Erland has... but here is a sample
Declare @error int Delcare @rowcount int Begin Tran INsert into yada yada Select @error = @@error, @rowcount = @@rowcount If @error !=0 OR @rowcount !=1 Begin Raiserror (yada yada Rollback tran Return -999 --if in SP End Commit Tran -- Show quoteWayne Snyder MCDBA, SQL Server MVP Mariner, Charlotte, NC I support the Professional Association for SQL Server ( PASS) and it''s community of SQL Professionals. "Lasse Edsvik" wrote: > Hello > > I was wondering if you could show me the most basic transaction in code? > > And rollback if error :) > > > > |
|||||||||||||||||||||||