Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
BRH 6
#SQLSERVERCE 5
#SQL SERVER 2
SQL Server CE 2
#SQLCE 2
#TSQL 2
SQL Server 2
TSQL 2
SQLSERVER COMPACT 2
SQLSERVERCE 2

Archive · View All
August 2010 6

How to use ExportSqlCE to migrate from SQL Server to SQL Compacts

Aug 12 2010 8:18AM by Erik Ejlskov Jensen   

Release 2.5 of the SQL Compact schema and data script utility Codeplex project contains a new command line utility, named Export2SqlCe, that allows you to export schema and data from a SQL Server 2005/2008 database in a SQL Compact compatible SQL format.

The Export2SqlCe tool does not create a SQL Compact sdf database file, but just creates a T-SQL script , that you can run with a tool like my SqlCeCmd Codeplex utility or SQL Server Management Studio 2008. This approach gives you the flexibility to modify the script in a text editor before creating the sdf file – but requires an extra step.

Below are the steps required to migrate a SQL Server database (tables and table indexes/constraints only) to a SQL Compact database.

First, run Export2SqlCe against your SQL Server database (2005 or 2008 are supported), using a command line similar to:

Export2sqlce "Data Source=(local);Initial Catalog=AdventureworksLT;Integrated Security=True" AW.sqlce

image_thumb3

This will create a file named C:\aw.sqlce – let’s have a look:

image_thumb4

This file contains a script to create tables, data and constraints (indexes and foreign keys), all in SQL Compact 3.5 compatible T-SQL dialect.

Then you can either open the aw.sqlce script in SQL Server Management Studio 2008 or use sqlcecmd to create the sdf file and populate the file based on the script – meaning the whole process can be run from a batch file and completely automated!

First create the database:

sqlcecmd -d "Data Source=C:\aw.sdf" -e create

Then run the generated script against the database:

sqlcecmd -d "Data Source=C:\aw.sdf" -i aw.sqlce > log.txt

Examine the log.txt to ensure no errors occurred- search for “error code” - I got an error from AdventureworksLT about an index that referred to a non-existing column.  If this happens, modify aw.sqlce to avoid any errors, or modify the source database.

Entire batch file:

Export2sqlce "Data Source=(local);Initial Catalog=AdventureworksLT;Integrated Security=True" AW.sqlce
sqlcecmd -d "Data Source=C:\aw.sdf" -e create
sqlcecmd -d "Data Source=C:\aw.sdf" -i aw.sqlce > log.txt
Republished with author's permission. See the original post here.

About the author

erik2

Erik Ejlskov Jensen, SQL Server [Compact] MVP, .NET and Windows Mobile Developer.
Erik has been using SQL Server Compact since version 1.0, and is a moderator of the SQL Server Compact MSDN Forum.
He looks forward to a bright future for SQL Server Compact 4.0, which can now be used with ASP.NET in addition to Windows Mobile and Windows desktop applications. See his  blog.

Tags: BRH, SQLSERVERCE, SQLSERVER COMPACT, #SQLSERVERCE,


Erik Ejlskov Jensen
292 · 0% · 147
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]