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 - Table does not exist

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-02-08 : 15:31:08
tahoo writes "Hi,
I will like to error checking for a stored procedure.

That is to check for the existence of some tables and views before the actual processing of the records.

I did for the checking:
IF object_id('tableA') IS NOT NULL


Then I use the table in Cursor:
DECLARE CurDelete CURSOR FAST_FORWARD FOR
SELECT tableA FROM field1
WHERE field1 NOT IN (
SELECT field1 FROM v_tableA)
OPEN CurDelete

However, when I test it by renaming the table to another name, this stored procedure does not seem to detect the error.

In fact, I think they failed even in precompiling (if there is much thing in MS-SQL)

Server: Msg 208, Level 16, State 1, Procedure sp_ImportView, Line 36
Invalid object name 'Table'.
Server: Msg 266, Level 16, State 1, Procedure sp_ImportView, Line -1
Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing. Previous count = 4, current count = 5.


Please advise"
   

- Advertisement -