You can use this Query to empty table TRUNCATE TABLE "table_name" ; i.e. TRUNCATE TABLE employee; In this way your table "employee" will be deleted & Re-Created with NO data in it by SQL Engine. And if you want to delete some records then use DELETE FROM "table_name" WHERE "condition"; i.e. DELETE FROM employee WHERE emp_id=5 AND emp_id=8; In this way the records will be deleted having ids 5 & 8 , rest of the table will remain as it was.
Make sure when you use TRUNCATE, it automatically saves the operation you do. If you use DELETE, you need to write a "COMMIT" to save the operation.
If you have to delete all the records from a table then "truncate" statement will work much faster than "delete" but for conditional deleting of records "delete" statment will work as "truncate" does not support conditional statments ...
Hi this is the SQL query to delete records from the table: TRUNCATE TABLE "table_name" ; if you want to delete some records then use this statement DELETE FROM "table_name" WHERE "condition"; If you wana get rid of table then use DROP table "table_name"; Hope this helps
delete *from tablename can potentially have a difference to truncate tablename when you have auto incrementing primary keys. Truncate may reset the auto increment counter
delete from table name ,it delete all records in your table so you can insert the data in the first line.
CREATE PROCEDURE sp_EmplyAllTable AS EXEC sp_MSForEachTable ‘ALTER TABLE ? NOCHECK CONSTRAINT ALL’ EXEC sp_MSForEachTable ‘DELETE FROM ?’ EXEC sp_MSForEachTable ‘ALTER TABLE ? CHECK CONSTRAINT ALL’ GO
for particular table you can use Delete function and all over table delete of database use Truncate table table_name
delete from table name use the query delete the all table contents you can insert the table first row.