Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete all data in a table in SQL CE?

SQL CE does not support TRUNCATE command. To clear a table I have to use DELETE. Is there a quicker/better way to clear the data then the following command?

DELETE FROM FooTable WHERE id !='ABC'
like image 789
KMC Avatar asked Apr 15 '11 06:04

KMC


People also ask

Which command in SQL is used to delete entire data?

The DELETE command is used to delete existing records in a table.

Which command is used to remove all data from table?

We can also use the TRUNCATE command to delete all the records from a table.

What is the fastest way to delete all of the rows in a table?

TRUNCATE TABLE removes all rows from a table, but the table structure and its columns, constraints, indexes and so on remain. The counter used by an identity for new rows is reset to the seed for the column. If you want to retain the identity counter, use DELETE instead.


1 Answers

You don't have any better way to do that, DELETE is the SQL Command for SQL CE to DELETE ROWS, anyway TRUNCATE TABLE deletes every row in a table, so your DELETE query must be executed also at SQL Server if you want to DELETE all the rows with id different from 'ABC'.

In the case you want to DELETE all the rows in SQL CE you must use

DELETE FROM FooTable

See you, I hope this post was useful to you.

like image 109
Amedio Avatar answered Sep 18 '22 18:09

Amedio