Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
please give replay with small example
Posted
Updated 4-Aug-13 20:14pm
v4

You are right that truncate is a DDL command.

TRUNCATE command works on table data not on table structure,It is used to delete all the rows from the table and free the space containing the table.
TRUNCATE command is used when you have to use that table again as if a table is dropped, all the relationships with other tables will no longer be valid, the integrity constraints will be dropped, grant or access privileges on the table will also be dropped, if want use the table again it has to be recreated with the integrity constraints, access privileges and the relationships with other tables should be established again. But, if a table is TRUNCATED, the table structure remains the same, therefore any of the above problems will not exist.


http://www.sqlserver-training.com/list-10-difference-between-truncate-delete-statement-in-sql-server/-[^]
 
Share this answer
 
Comments
Nag226 5-Aug-13 3:19am    
Thank u one and all to give valuable replay
Adarsh chauhan 5-Aug-13 3:20am    
you are most welcome.. :)
You can only delete data with delete and truncate, to delete a database you have to use drop database, see: http://technet.microsoft.com/en-us/library/ms178613.aspx[^]
 
Share this answer
 
 
Share this answer
 
The delete and truncate effect on table data. Not database.

If you want to delete database, you can use drop statement.

http://msdn.microsoft.com/en-us/library/ms178613.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900