Pages

Thursday, June 4, 2009

Is TRUNCATE faster to delete the data from a table?

When I want to delete all the records from a table, the only command that comes to my mind is TRUNCATE. Is there any command that is faster than TRUNCATE to delete the data? Answer YES. Instead of issuing TRUNCATE on a table, you can simply rename the table and CREATE new table with the same structure. Drop the Old table when there is less load on the server.

When we perform RENAME or DROP operations on a table, all the objects which depends on the table gets invalidated. So use sp_recompile stored procedure to compile all the objects which depends on this table.

No comments: