Write the Stored Procedure (SQL Server 2005) in the previous work, declare a table variable, In the select... when using the from Table variable name, press ENTER plug-in SQL prompt 4 to automatically add [] brackets to the table variable name. At that time, I was not aware of any problems, if you press F5 to alter the stored procedure, no compilation error is prompted. An error occurred while executing the stored procedure:
Message 208, level 16, status 1, process Test2, 9th rows
The object name '@ temp_id' is invalid.
The stored procedure is as follows:
Code Set ansi_nulls on
Go
Set quoted_identifier on
Go
Create proc [DBO]. [Test2]
As
Declare @ temp_id table
(
[ID] [varchar] (18) not null
Primary Key
)
Begin try
Select *
From [@ temp_id]
End try
Begin catch
Print 'error occurred'
End catch
It is strange that SQL server does not report an error during the create or alter stored procedure. An error occurs when the stored procedure is executed. Moreover, this error cannot be caught by the try... Catch Block. What is the principle? I wonder if the cool guys in the yard can explain it?
Therefore, after creating and modifying the stored procedure, you can try to execute it and see if there is any error.