Thursday, March 22, 2012

Creating Temporary within Stored Procedure

I'm creating a temporary table within my stored procedure should I add a
drop temporary table statement at the end of my stored procedure so that if
stored procedure fails the temporary table will be dropped?
Thanks
No need to; SQL Server will automatically drop the temporary table when the
procedure returns, regardless of whether it was successful or not.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
"Joe K." <Joe K.@.discussions.microsoft.com> wrote in message
news:AB48F052-B137-4F70-A124-2AFF800FB984@.microsoft.com...
> I'm creating a temporary table within my stored procedure should I add a
> drop temporary table statement at the end of my stored procedure so that
if
> stored procedure fails the temporary table will be dropped?
> Thanks

No comments:

Post a Comment