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.
| Author |
Topic |
|
desikankannan
Posting Yak Master
152 Posts |
Posted - 2010-06-07 : 07:24:56
|
| Hi,iam was using sqlerver 2000 but now we are going to use sql 2005,pls explain how to use try and catch with method with begin trans,commit trans, rollback trans.Desikankannan |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-07 : 07:28:43
|
http://www.sqlteam.com/article/handling-sql-server-errors No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2010-06-07 : 08:13:46
|
| [code]create proc testasbegin begin try begin transactiondeclare @id intinsert into table1 (columns) select columns......select @id = scope_identity()insert into table2(columns)select @id,........commit transactionend trybegin catchrollback transactionselect error_message()return -1end catchend[/code] |
 |
|
|
|
|
|