We usually use delete command in our sql scripts but we don’t know why we do not use truncate command.
Basically when we use the delete the table we actually deleting records from database’s table and maintaining the logs of deleting records. Like when we delete some thing from our computer and it goes to recycle bin.
But when we use truncate table command then we tell sql server that we don’t need logs of deleted records. Like when we delete some thing from our computer by Shift Delete.
So, we should use truncate and delete according to the circumstances because we should know that truncate command much faster than delete.
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE PROCEDURE [dbo].[USP_TEST] AS
Truncate Table tblTest
INSERT INTO [tblTest]
where TestCol1 = ‘Test’