title: How to find a SQL Server 2008 instance, including default instance
body: <p>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.</p>
  
  <p>Right now I am using the <code>SmoApplication.EnumAvailableSqlServers</code> 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.</p>
  
  <p>I don't want to just blindly check and see if the traditional <code>MSSQLSERVER</code> default instance works for two reasons:</p>
  
  <ol>
  <li><p>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.</p></li>
  <li><p>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.</p></li>
  </ol>
  
  <p>SO I need to use any SQL Server 2008 named instance, or a default instance IF it is 2008. </p>
  
  <p>Is there any way to do this?</p>