Tibor Karaszi, SQL Server MVP
For help on TSQL, give us something we can execute in Query Analyzer
I know it's not directly answering the question, but if you're on SQL 2000,
automatically cleaned up at the end of scope (eg stored procedure / batch).
They also have less logging overhead than temp tables and can in many cases
run considerably faster than temp tables.
Quote:> I am creating a temp table at the beginning of a stored
> procedure and dropping it at the end (I can't use #temp
> because I am doing dynamic SQL with the execute command).
> My problem is if for some reason the stored procedure
> fails the first time, then the table doesn't get dropped.
> I end up having to manually drop it.
> I want to put a line at the beginning of the stored
> procedure to drop the temp table if it exists.
> How would I check to see if the table exists?
> Or how could I turn off error trapping so that if the drop
> table fails, it wouldn't care?
Does anyone know how to trap errors in a stored procedure?
I am executing 'dump transaction' statements to dump the logs for all my databases.
The first log that fails to dump stops the procedure, and the remaining logs don't get processed.
Thanks for any help.
2. Error 1001