user366312
user366312

Reputation: 16988

How to convert a SQL Server database to other format so that I can deploy it without SQL Server service?

I have developed several desktop applications which use SQL Server 2005 Express.

Now I need to deploy my applications in an environment where a service of SQL Server is not expected.

I need a mechanism so that I can only use the .MDF file or otherwise convert the file to such a format so that I can deploy my application without running the SQL Server 2005 service.

What can I do?

Remember, the database designs are moderately complex. So I am trying to avoid recreating MS Access files. Using SQLite may be an option. But I am trying to avoid changing my source-codes.

Upvotes: 0

Views: 121

Answers (3)

Rich Turner
Rich Turner

Reputation: 11014

While Dai makes some good points, I think you may also find value in considering SQL Server 2012's LocalDB. This is essentially the same DB engine that powers SQL Express and SQL server, but it is run automatically as a child exe of the client application, not as a service like SQLExpress and SQLServer are.

This post compares LocalDB,SQL Compact, SQL Express and SQL Server: http://blogs.msdn.com/b/jerrynixon/archive/2012/02/26/sql-express-v-localdb-v-sql-compact-edition.aspx

Upvotes: 1

David Wilson
David Wilson

Reputation: 177

SQL Server Compact Edition could work if you can live with its limitations, such as a maximum database size of 4 GB. You would need to convert the .mdf file to the .sdf format used by SQL CE, and here is instructions on how to do that.

Upvotes: 0

Dai
Dai

Reputation: 155433

In short, you can't.

Unless your database is a simple set of tables, with only the simplest of relations and joins, and you only perform simple CRUD operations (which your post implies is otherwise) then you cannot have a database that is portable between RDBMS engines.

Traditionally you'd abstract-away your data access layer with some common interface and then implement RDMBS-specific queries and commands, e.g.

public interface IDatabase {
    Account GetAccount(Int64 accountId);
    Account[] GetAccounts(Int32 page, Int32 pageSize, out Int32 totalRecords);
    etc...
}

public class MSSqlServerDatabase : IDatabase {
}

public class MySqlServerDatabase : IDatabase {
}

However, you're probably better-off moving to SQLite, because it's completely portable and will work anywhere. It doesn't involve installing any services either. Bite the bullet :)

Upvotes: 0

Related Questions