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 |
ranjeetsingh_6
Posting Yak Master
125 Posts |
Posted - 2007-08-30 : 06:47:38
|
Hi I am new for exception Handling in SQL Server 2000.How to handle iti use like this for Invalid object name error user freindly.---------------------------------------------Declare @error intselect * from TableNotExistset @error=@@Errorif @error<>0print 'Table Not Exist'elseprint 'Table Exist'-----------------------------But above code give outputServer: Msg 208, Level 16, State 1, Line 1Invalid object name 'TableNotExist'.Ranjeet Kumar Singh |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-30 : 06:56:45
|
If exists(select * from sysobjects where name='TableNotExist' and xtype='u')print 'Table Exists'elseprint 'Table Not Exist'MadhivananFailing to plan is Planning to fail |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-30 : 07:09:30
|
replace @@ERROR with @@ROWCOUNT E 12°55'05.25"N 56°04'39.16" |
 |
|
ranjeetsingh_6
Posting Yak Master
125 Posts |
Posted - 2007-08-30 : 07:10:03
|
Thanksbut if i write a wrong update query on any existing table and want to return @@Error value how it will done i use like this but not return@@Error value.Note:-Actully I want to Storing error messages in the error_log table makes it easy to trace for future. --------------------------Declare @error intupdate tblbillentry set fltbillitemqty ='aaa'set @error=@@Errorif @error<>0print 'Can not convert varchar to numeric.'elseprint @error-------------Ranjeet Kumar Singh |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-30 : 08:02:03
|
www.sommarskog.se/Error-Handling-I.htmlwww.sommarskog.se/Error-Handling-II.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|