Search code examples
batch-filesql-server-ce

Batch script to delete all records from a SQL Server CE database table


Need a batch script to delete all records in a SQL Server CE database table. Don't know if its possible, I'm weak in scripting.


Solution

  • You can use my SqlCeCmd/SqlCeCmd40 command line utility from a batch file, with a command line like:

    sqlcecmd -d "Data Source=C:\mydb.sdf" -q "DELETE * FROM MyTable"
    

    (Or DROP the table and recreate with CREATE TABLE - faster)

    Download from http://sqlcecmd.codeplex.com