Search code examples
sql-server-ce

How to Shrink SQL Server CE Database using SQL


I am using SQL Server CE databases on our clients machines, and I was wondering if there is a way to shrink the database using SQL?

In SQL Server you do this,

DBCC SHRINKDATABASE

Is there something like this for SQL Server CE?

Unfortunately I don't have the facility to run this command using C# like this,

SqlCeEngine.Shrink

without some kind of software change.


Solution

  • There is no way to do this via SQL.

    You can use my sqlcecmd command line tool to Compact the database (better than shrink):

    sqlcecmd -d "Data Source=C:\Northwind.sdf" -e compact