Quantcast
Channel: SCN: Message List - SAP Advantage Database Server
Viewing all articles
Browse latest Browse all 997

Re: Store Procedures do not delete temp tables created in that procedure

$
0
0

Hi Dave,

 

That would be expected.  The temp table will continue to be available until it is dropped or the connection is closed.

 

This behavior lets a Stored Procedure create and populate a temp table that is then available to further query at a later time if needed (i.e. another sql statement or another stored procedure)

 

There are two possibilities.

 

A) Use a TRY/CATCH block to create the table / delete the contents

TRY

Create table #tempSVGM ....
CATCH ALL

delete from #tempSVGM...
END TRY

 

B) Use an if exists with sp_GetTables
if exists execute procedure sp_GetTables(null, null, 'tempSVGM', 'LOCAL TEMPORARY').....

 

(I've not had a chance to try B, but I'm confident it would work).

 

Edgar


Viewing all articles
Browse latest Browse all 997

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>