I am creating a Windows form application that uses SQL Server 2008. In the setup project that I have I check for and install SQL Server 2008 if necessary on the target machine. What I need is a way to get a SQL Server 2008 - and ONLY 2008 - instance name.
Right now I am using the SmoApplication.EnumAvailableSqlServers function and checking the versions returned, but what I have found is that it does not display the default instance. This is problematic for me because if this program is being run after my installer setup SQL Server 2008 on the target machine, there are no named instances available - only the default instance.
I don't want to just blindly check and see if the traditional MSSQLSERVER default instance works for two reasons:
It could be the default instance left over from a SQL Server 2008 install, which won't be able to access the DB used by my application. Skipping it and then checking for other named instances would most likely return me nothing.
It could also be the default instance from a newer version of SQL Server 2012. While this instance would be able to access my DB, my experience is that it then "upgrades" the DB to the new SQL Server version, and earlier versions won't be able to access it. Since my application is intended to work with SQL Server 2008, this presents me with some problems.
SO I need to use any SQL Server 2008 named instance, or a default instance IF it is 2008.
Is there any way to do this?