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 2000 Forums
 SQL Server Development (2000)
 Error handling - invalid table

Author  Topic 

sanctos
Starting Member

19 Posts

Posted - 2007-02-09 : 16:51:31
Hi everyone,

I am having trouble being able to handle an error that calls an non-existing table name. I am just doing this for testing purposes. Any ideas?

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-02-09 : 17:51:52
Instead of trapping an error, why don't you just check to make sure the table exists before trying to access it?

This code shows one way to check if a table exists.

if objectproperty(object_id('dbo.MyTable'),'IsUserTable') = 1
begin
select * from dbo.MyTable
end


CODO ERGO SUM
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-02-12 : 12:21:00
quote:
Originally posted by Michael Valentine Jones

Instead of trapping an error, why don't you just check to make sure the table exists before trying to access it?



Can you imagine?

Too bad the sproc doesn't fail on compile like DB2



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -