Created
July 7, 2013 14:27
-
-
Save jrotello/5943638 to your computer and use it in GitHub Desktop.
Enumerate over all available SQL Server instances.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DataTable data = SqlDataSourceEnumerator.Instance.GetDataSources(); | |
foreach(DataRow row in data.Rows) { | |
string server = row["ServerName"].ToString(); | |
string instance = row["InstanceName"].ToString(); | |
if (!string.IsNullOrWhiteSpace(instance)) { | |
server += "\\" + instance; | |
} | |
Console.WriteLine(server); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment