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 |
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-16 : 12:00:23
|
How to avoid deadlocks with the below SP..create procedure dbo.test as BEGIN TRY select * into std1 from student1END TRYBEGIN CATCH EXEC dbo.ErrorInfo_sp 'St1tableERROR' RETURNEND CATCHBEGIN TRYselect * into std2 from student2END TRYBEGIN CATCH EXEC dbo.ErrorInfo_sp 'St2tableERROR' RETURNEND CATCHBEGIN TRYUpdate st1 set name ='test' wehre x=1END TRYBEGIN CATCH EXEC dbo.ErrorInfo_sp 'St1UpdatetableERROR'END CATCHBEGIN TRYupdate st2 set zipcode='299' where zipcode is nullEND TRYBEGIN CATCH EXEC dbo.ErrorInfo_sp 'St2UpdatetableERROR' RETURNEND CATCH |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-16 : 12:21:58
|
i think only common point in above code is dbo.ErrorInfo_sp . what does this sp do?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-16 : 13:07:36
|
Basically it is error info.-- Create procedure to retrieve error information. CREATE PROCEDURE dbo.usp_GetErrorInfo @custom varchar(255) AS BEGIN SET NOCOUNT ON; SELECT ERROR_NUMBER() AS ErrorNumber ,ERROR_SEVERITY() AS ErrorSeverity ,ERROR_STATE() AS ErrorState ,ERROR_PROCEDURE() AS ErrorProcedure ,ERROR_LINE() AS ErrorLine ,ERROR_MESSAGE() AS ErrorMessage ,@custom as ErrorCustom; END |
 |
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|