Click here to Skip to main content
15,888,733 members
Home / Discussions / Database
   

Database

 
QuestionOptimize an query select DB Pin
TuanNGUYEN19-Jan-09 16:48
TuanNGUYEN19-Jan-09 16:48 
AnswerRe: Optimize an query select DB Pin
Wendelius19-Jan-09 18:19
mentorWendelius19-Jan-09 18:19 
GeneralRe: Optimize an query select DB Pin
TuanNGUYEN19-Jan-09 20:04
TuanNGUYEN19-Jan-09 20:04 
GeneralRe: Optimize an query select DB Pin
Wendelius20-Jan-09 8:28
mentorWendelius20-Jan-09 8:28 
Question"begin catch" and "end catch" Pin
George_George19-Jan-09 2:38
George_George19-Jan-09 2:38 
AnswerRe: "begin catch" and "end catch" Pin
J4amieC19-Jan-09 4:02
J4amieC19-Jan-09 4:02 
GeneralRe: "begin catch" and "end catch" Pin
George_George19-Jan-09 18:41
George_George19-Jan-09 18:41 
AnswerRe: "begin catch" and "end catch" Pin
Rob Philpott19-Jan-09 6:29
Rob Philpott19-Jan-09 6:29 
Begin/End catch was added in Sql Server 2005 and is kind of handy to avoid having to check the status of @error at multiple points in your stored proc.

The code you've pasted looks like it would belong in a catch. A common pattern looks something like this:

begin transaction
begin try
  ...
  ... 
  ...
  commit transaction
end try
begin catch
  rollback transaction
  raiserror(ERROR_MESSAGE(), ERROR_SEVERITY())
end catch


You don't need to check @error any more - that is implied by reaching the catch block. Can't see any point in checking @@trancount either - either the commit or the rollback will get hit.

Regards,
Rob Philpott.

GeneralRe: "begin catch" and "end catch" Pin
George_George19-Jan-09 18:40
George_George19-Jan-09 18:40 
GeneralRe: "begin catch" and "end catch" Pin
Rob Philpott19-Jan-09 23:13
Rob Philpott19-Jan-09 23:13 
GeneralRe: "begin catch" and "end catch" Pin
George_George20-Jan-09 3:01
George_George20-Jan-09 3:01 
GeneralRe: "begin catch" and "end catch" Pin
Rob Philpott20-Jan-09 3:13
Rob Philpott20-Jan-09 3:13 
AnswerRe: "begin catch" and "end catch" Pin
Wendelius19-Jan-09 7:06
mentorWendelius19-Jan-09 7:06 
GeneralRe: "begin catch" and "end catch" Pin
George_George19-Jan-09 18:51
George_George19-Jan-09 18:51 
GeneralRe: "begin catch" and "end catch" Pin
Wendelius20-Jan-09 6:39
mentorWendelius20-Jan-09 6:39 
AnswerRe: "begin catch" and "end catch" Pin
Hamid_RT22-Jan-09 23:18
Hamid_RT22-Jan-09 23:18 
QuestionConvert Columns as Rows Pin
Vignesh Krishnan19-Jan-09 1:40
Vignesh Krishnan19-Jan-09 1:40 
AnswerRe: Convert Columns as Rows Pin
Wendelius19-Jan-09 2:05
mentorWendelius19-Jan-09 2:05 
GeneralRe: Convert Columns as Rows Pin
Vignesh Krishnan19-Jan-09 3:12
Vignesh Krishnan19-Jan-09 3:12 
GeneralRe: Convert Columns as Rows Pin
Wendelius19-Jan-09 6:55
mentorWendelius19-Jan-09 6:55 
GeneralRe: Convert Columns as Rows Pin
Vignesh Krishnan19-Jan-09 8:45
Vignesh Krishnan19-Jan-09 8:45 
GeneralRe: Convert Columns as Rows Pin
swjam19-Jan-09 11:26
swjam19-Jan-09 11:26 
GeneralRe: Convert Columns as Rows Pin
Vignesh Krishnan20-Jan-09 2:10
Vignesh Krishnan20-Jan-09 2:10 
GeneralRe: Convert Columns as Rows Pin
ColinM12319-Jan-09 11:45
ColinM12319-Jan-09 11:45 
GeneralRe: Convert Columns as Rows Pin
Wendelius20-Jan-09 8:17
mentorWendelius20-Jan-09 8:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.