How do I write and run an upgrade script for .sdf databases?
How do I write and 开发者_开发问答run an upgrade script for .sdf databases? Would sqlcmd be able to do that? I am not trying to upgrade the version of the database file. I am trying to upgrade the schema and data inside of it.
Rewritten
You can use SQL Compact's TSQL commands, such as ALTER TABLE and UPDATE.
This can be done with your choice of client, whether inside an application using the SqlServerCe namespace methods (you'll need to reference the SQL Compact library) or with a client like SQL Server Management Studio.
Just remember that SQL Compact only allows one process to be connected to the database at a time.
You can run a script against a SQL CE database manually as follows:
- Open Microsoft SQL Server Management Studio
- Click New Query on the toolbar. A dialog headed "Connect to server" comes up
- Set Server Type to "SQL Server Compact Edition"
- For the Database file field enter the full path to the
.sdf
file - click Connect
You should get a query window which you can use to execute scripts in the usual way. And see the database in the Object explorer.
精彩评论