views:

5999

answers:

3

Looking for a way to programatically, or otherwise, add a new instance of SQL 2005 Express Edition to a system that already has an instance installed. Traditionally, you run Micrsoft's installer like I am in the command line below and it does the trick. Executing the command in my installer is not the issue, it's more a matter of dragging around the 40 MBs of MS-SQL installer that I don't need if they have SQL Express already installed. This is what my installer currently executes:

SQLEXPR32.EXE /qb ADDLOCAL=ALL INSTANCENAME=<instancename> SECURITYMODE=SQL SAPWD=<password> SQLAUTOSTART=1 DISABLENETWORKPROTOCOLS=0

I don't need assistance with launching this command, rather the appropriate way to add a new instance of SQL 2005 Express without actually running the full installer again.

I'd go into great detail about why I want to do this but I'd simply bore everyone. Suffice to say, having this ability to create a new instance without the time it takes to reinstall SQL Express etc. would greatly assist me for the deployment of my application and it's installer. If makes any difference to anyone, I'm using a combination of NSIS and Advanced Installer for this installation project.

A: 

I do not know how to do it with an API, but if no one gives a better solution, you can always use Process.Start() to execute your command line as-is.

daughtkom
+1  A: 

It sounds like a user instance might help you. If you have the MDF and LDF files, you can connect to the files by instructing SQL Server Express to launch a user instance and attach the specified file to that instance.

This artile http://msdn.microsoft.com/en-us/library/bb264564.aspx has a good description of how you can lean on the existing SQL Server Express installation to instantiate a user-specific instance for the duration of your connection.

Hope it helps.

Bernhard Hofmann
A: 

After months/years of looking into this it appears it can't be done. Oh well, I guess I just reinstall each time I want a new instance. I guess it's because each instance is it's own service.

Douglas Anderson