944768 wrote:I would suggest TRUNCATE if the whole data is to be removed..
I have a sp , it delets records then insert some record in a table when ever it runs.
it's a offline sp.What does that mean?
truncation is better or deleting or droping and creating it again.truncate is better than delete - it will reset the HWM, release the space occupied. But there are differences - ON DELETE triggers will not get executed in case of TRUNCATE, if there are any. TRUNCATE is auto COMMIT as it is a DDL. You cannot directly write TRUNCATE statement in an SP , you need to use dynamic SQL..
please tel me above with respect to GTT(trnasaction level) and normal tabel?GTT is just like a normal table (operationally) except that the data will be visible for the session by which it is operated..
Chanchal Wankhade wrote:... for certain values of "always".
Truncate is alway's better than delete.
944768 wrote:You shouldn't need to truncate a global temporary table. And you definitely don't need to truncate if it's a transaction level temporary table: a commit or a rollback will suffice to wipe its data.
--That means even GTT (transaction level ) will be in good health if 'truncate is used.