How to List SQL Server Instance Names

There is several ways to find Installed SQL Server Instance Names

1.Via Command Prompt

sql1

2.via SQL Query

sql2

3. via .Net

void Main()
{
Microsoft.Win32.RegistryKey baseKey = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64);
Microsoft.Win32.RegistryKey key = baseKey.OpenSubKey(@”SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL”);

foreach (string s in key.GetValueNames())
{
//MessageBox.Show(s);
Console.WriteLine(s);
}

key.Close();
baseKey.Close();
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s