Click here to Skip to main content
Click here to Skip to main content

SQL Server to SQL Server Compact Edition Database Copy Utility

By , 26 Jun 2008
 

UPDATE

Please download the latest version of this tool from JohnnyCantCode.com. I have updated this utility based on some feedback from users.

I added the ability to select the schema you wish to copy. For most databases, this will simply be "dbo".

I fixed a bug where the application did not recognize a valid version of "System.Data.SqlServerCe.dll".

Introduction

This utility will copy the schema and data from a normal SQL Server 2000/2005 database and export it to a SQL Server Compact Edition database. The tool supports version 3.1 or 3.5 of SQL Server Compact Edition.

Background

I was working on a mobile application and needed an easy way to manage the table relationships and indexes without having to resort to scripting. I was familiar with using SQL Server Management Studio so I decided that I would write a utility that converted a normal SQL Server database to a mobile database. This way, I could continue using the tool I normally use to create and maintain my databases.

Using the Code

Feel free to take a look at the code and offer your most gracious comments. The application uses a wizard to walk you through converting a database. I have also included a normal WINFORM that also does the conversion, but I stopped development on this in lieu of the wizard, so the form is incomplete. I will be maintaining this code and writing more about it on my blog at www.JohnnyCantCode.com. You can find the original post here.

Points of Interest

This utility will copy Indexes, Primary Keys, Foreign Keys, Table structure and data. SQL Server Compact Edition does not have support for Views, Triggers nor Stored Procedures, therefore this utility does not copy these.

History

  • 1.0 Initial release

License

This article, along with any associated source code and files, is licensed under The BSD License

About the Author

johnnycantcode
Software Developer (Senior) Gologic Tech LLC.
United States United States
Member
I work as an independent software architect and senior developer. I have worked on many large enterprise projects as well as small single user applications.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralGreat tool - after some manual changes :-)memberdolbysys18 Feb '13 - 21:16 
GeneralRe: Great tool - after some manual changes :-)memberpmiossec27 Feb '13 - 12:45 
GeneralRe: Great tool - after some manual changes :-)memberronan_mc25 Apr '13 - 13:07 
GeneralRe: Great tool - after some manual changes :-)memberpmiossec28 Apr '13 - 1:43 
Questiongeht nicht!memberMember 250914025 Jan '13 - 4:56 
nach konvertierung in VS.2012 lässt sich das Programm nicht starten Frown | :-(
AnswerRe: geht nicht!memberdolbysys18 Feb '13 - 21:20 
QuestionMdf----_> sdf and sdf ----> mdfmembercjgallardo9629 Oct '12 - 3:03 
Questionasm.GetType("System.Data.SqlServerCe.SqlCeEngine"); returns nullmemberbradut15 Oct '12 - 11:25 
AnswerRe: asm.GetType("System.Data.SqlServerCe.SqlCeEngine"); returns nullmemberJeff Wharton2 Jan '13 - 18:01 
QuestionMy vote of 5memberSPI24 Aug '12 - 7:20 
GeneralMy vote of 5memberBig D27 Apr '12 - 9:40 
GeneralMy vote of 5membermanoj kumar choubey17 Apr '12 - 2:21 
GeneralMy vote of 5memberfootnote9 Sep '11 - 8:28 
QuestionIs there anyone able to make it work with SQL Server 2008 R2?memberEhsan.thabit21 Jun '11 - 8:14 
GeneralSupport for Compact edition v3.5 sp2memberjcgk_7713 Apr '11 - 2:32 
GeneralRe: Support for Compact edition v3.5 sp2memberMember 849633121 Mar '12 - 9:40 
QuestionJohnny Can't Code?memberMember 78058094 Apr '11 - 5:43 
Generalgetting error just-in-time (JIT) debugging instead of this dialog boxmemberpsnlakshmi30 Oct '10 - 1:40 
GeneralBad Image Format Exceptionmemberi_lonsdale@hotmail.com15 Oct '10 - 22:43 
Generalproblem with varbinarymemberpgarbo17 Aug '10 - 5:05 
GeneralThanksmemberUros Calakovic8 Aug '10 - 2:00 
QuestionException where Copying DatabasememberEdgarVegaD14 Jan '10 - 4:36 
AnswerRe: Exception where Copying DatabasememberEdgarVegaD14 Jan '10 - 8:14 
AnswerRe: Exception where Copying Databasememberdille421 May '10 - 3:34 
GeneralGETUTCDATE() & Multi-Column Key'smembermichael@merlot.com21 Nov '09 - 4:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 26 Jun 2008
Article Copyright 2008 by johnnycantcode
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid