Developing Matt

My Technical Journal

List All Sql Servers

leave a comment »

Thank you Mister Clay for providing me a quick and easy way to get all the sql servers on my network.  Here is his code (from here):

Private Sub btnRetrieve_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Dim sqlList As SQLDMO.NameList = Nothing

Dim sqlApp As SQLDMO.Application = Nothing



sqlApp = New SQLDMO.Application

sqlList = sqlApp.ListAvailableSQLServers

Dim ctr As Integer = 1

While ctr <= sqlList.Count


System.Math.Min(System.Threading.Interlocked.Increment(ctr), ctr – 1)

End While

Catch ex As Exception



If Not (sqlList Is Nothing) Then

sqlList = Nothing

End If

If Not (sqlApp Is Nothing) Then

sqlApp = Nothing

End If

End Try

End Sub

Attached also is the working sample done using C#. Notes though, SQLDMO should be referenced and the DLL can be found in C:\Program Files\Microsoft SQL Server\80\Tools\Binn.

Published 06-09-2006 10:30 AM by MisterClay


Written by matt

January 12, 2009 at 10:17 am

Posted in Sql Server

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: