All Type Coding

Search Here

How to truncate a table in sql server.?


Truncate Statement

Truncate statement clears all the data from a table without any condition.you can not use WHERE clause with truncate command.

Syntax of Truncate
                      TRUNCATE TABLE [Table_Name]

Now we'll learn here. how to truncate a table step by step.

step1.  Create a table.
CREATE TABLE [dbo].[Employee1](
     [Id] [int]NULL,
     [Name] [varchar](50) NULL,
     [salary] [varchar](60) NULL,
     [Gender] [varchar](10) NULL

)


















step2. Set identity and primary key on ID column.




































step3. I
nsert records into the table.































Step4.  Execute the select statement 




























Step5. Now we'll truncate Employee1 table 
















Now execute the statement table.














There is no data in Employee1 table thus we can truncate the data from  data table.

No comments :

Post a Comment