Saturday 15 March 2008

Load SQL Server file at runtime without attaching the mdf file

There are situations where you want a quick and easy deployment for an application that runs from a SQL Server file and you don't want the user to have to have SQL Server client tools installed to attach to the mdf file etc. For instance if your app is a standalone desktop application where each user will use a db installed in the application folder.

In these scenarios, use the technique described in this article....

http://technet.microsoft.com/en-us/library/ms165716.aspx

It allows you to deploy an mdf file in the applications install folder and will load, or lift, that SQL Server database when the application runs without any need to attach the database .mdf file to an instance of SQL Server engine.

The user will need to have either SQL Server or the free SQL Server Express installed on their machine. Because SQL Server Express is free though and available as download from Microsoft this is usually not a problem.

One thing to consider with Vista though are the permission implications.....

http://blog.benhall.me.uk/2008/03/sql-server-and-vista-create-database.html

No comments: