Quantcast
Viewing all articles
Browse latest Browse all 8526

Re: CREATE TABLE ... AS SELECT query with placeholders fails

Hi Lars,

 

Lars Breddemann wrote:

 

The other thing is: if you just want to refer to the result set later on, it's much better to use table variables instead of temp. tables.

 

 

Have a question, can you throw some more light on the above statement on why using Table variables are better than temp. tables?

 

My observations on using Temp Tables below:

 

1) Locking may happen when multiple users use that procedure, but as it is a session specific structure i did not see it happen  ( need your inputs whether my understanding was correct )

 

2) When users increase i saw performance degrading a considerable rate for Temporary tables i was thinking it to be because of "insert" operation cost is it correct?

 

3) Only advantage with temp tables i saw is when you want to perform some logic instead of doing on entire data set, you can use a limited scope data which you can insert into temporary table ( if dynamic filters we can use Exec ) and further use it.

 

Even in the implementation we did we are asked to remove Temp tables as much as possible and then it is where we used EXEC IMMEDIATE. ( We need to use because we had a lot of filters close to 30 and multiple if else blocks ) to remove the temporary tables we used in our procedures.

 

Could you please help me to understand the differences better and why table variables are preferred over to Temp Tables? And why Temp tables have should not be used ?

 

 

Regards,

Krishna Tangudu


Viewing all articles
Browse latest Browse all 8526

Trending Articles