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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Try

Author  Topic 

svjith
Starting Member

5 Posts

Posted - 2009-12-12 : 09:00:22


BEGIN TRY
-- Generate divide-by-zero error.

SELECT 1/0;
END TRY
BEGIN CATCH
print 'Catched'
END CATCH;
this print Catched fine.

--BUT--

BEGIN TRY
-- Generate divide-by-zero error.

SELECT * from ATableNotExistingInMydb
END TRY
BEGIN CATCH
print 'Catched'
END CATCH;
this is not printing Catched
why ? :( this print only :
Invalid object name 'ATableNotExistingInMydb'



tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-12 : 13:03:05
You can't "catch" an exception like that.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -