Home All Groups Group Topic Archive Search About

HOWTO: List SQL Servers on Local Machine

Author
10 Apr 2006 2:37 PM
Scott
Hi All,

I need to retrieve a list of SQL servers that are running on a local machine.

I have tried using:
   SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance;
   System.Data.DataTable table = instance.GetDataSources();
but have found that it returns servers on the entire network not on the
local machine.

Is there some other C# API that can be used to get a list of SQL servers
that are running on the local machine?

Thanks in advance for any help,
Scott

Author
10 Apr 2006 4:01 PM
William (Bill) Vaughn
I have used these methods many times to demonstrate access to servers on the
local machine and anywhere else visible on the net. Are the local servers
configured so as to make them "visible"? Is the SqlBrowser service running?
Are the ports and protocols enabled?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Show quote
"Scott" <Sc***@discussions.microsoft.com> wrote in message
news:5B8FB955-666F-4848-8A64-216DF5C8CBC6@microsoft.com...
> Hi All,
>
> I need to retrieve a list of SQL servers that are running on a local
> machine.
>
> I have tried using:
>   SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance;
>   System.Data.DataTable table = instance.GetDataSources();
> but have found that it returns servers on the entire network not on the
> local machine.
>
> Is there some other C# API that can be used to get a list of SQL servers
> that are running on the local machine?
>
> Thanks in advance for any help,
> Scott
Author
10 Apr 2006 4:12 PM
Scott
Hi Bill,

Yes, the local servers are visible and SqlBroswer service is running.
Not sure about ports and protocols. However the two servers I am intersted
in(SQLEXPRESS and MSSQLSSERVER-MSDE) are visible SQL Server Configuration
Manager.

Show quote
"William (Bill) Vaughn" wrote:

> I have used these methods many times to demonstrate access to servers on the
> local machine and anywhere else visible on the net. Are the local servers
> configured so as to make them "visible"? Is the SqlBrowser service running?
> Are the ports and protocols enabled?
>
Author
11 Apr 2006 3:57 PM
William (Bill) Vaughn
Did you run the SQL Server Surface Area Configuratoin tool?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Show quote
"Scott" <Sc***@discussions.microsoft.com> wrote in message
news:A9219BF1-C1EA-44C6-AF25-70DC6EABAA63@microsoft.com...
> Hi Bill,
>
> Yes, the local servers are visible and SqlBroswer service is running.
> Not sure about ports and protocols. However the two servers I am intersted
> in(SQLEXPRESS and MSSQLSSERVER-MSDE) are visible SQL Server Configuration
> Manager.
>
> "William (Bill) Vaughn" wrote:
>
>> I have used these methods many times to demonstrate access to servers on
>> the
>> local machine and anywhere else visible on the net. Are the local servers
>> configured so as to make them "visible"? Is the SqlBrowser service
>> running?
>> Are the ports and protocols enabled?
>>
Author
11 Apr 2006 4:23 PM
Jeff Dillon
Bill, I think he is saying he is getting ALL servers. He just wants to
enumerate those on the local machine. He is getting these, plus the rest of
the network, too

Jeff

Show quote
"William (Bill) Vaughn" <billvaRemoveT***@nwlink.com> wrote in message
news:uYBIpCYXGHA.3724@TK2MSFTNGP02.phx.gbl...
> Did you run the SQL Server Surface Area Configuratoin tool?
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> INETA Speaker
> www.betav.com/blog/billva
> www.betav.com
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> __________________________________
>
> "Scott" <Sc***@discussions.microsoft.com> wrote in message
> news:A9219BF1-C1EA-44C6-AF25-70DC6EABAA63@microsoft.com...
>> Hi Bill,
>>
>> Yes, the local servers are visible and SqlBroswer service is running.
>> Not sure about ports and protocols. However the two servers I am
>> intersted
>> in(SQLEXPRESS and MSSQLSSERVER-MSDE) are visible SQL Server Configuration
>> Manager.
>>
>> "William (Bill) Vaughn" wrote:
>>
>>> I have used these methods many times to demonstrate access to servers on
>>> the
>>> local machine and anywhere else visible on the net. Are the local
>>> servers
>>> configured so as to make them "visible"? Is the SqlBrowser service
>>> running?
>>> Are the ports and protocols enabled?
>>>
>
>
Author
12 Apr 2006 6:05 PM
Scott
Jeff and Bill,

Yes, what I would like to be able to do is have initially a list of only the
SQL servers that are local to the machine.
Similar to the dialog the comes up when running Micorsoft SQL Server
Management Studio: It's initial dropdown shows (which is very fast):
    MYMACHINENAME/SQLEXPRESS
    MYMACHINENAME
    <Browse for more...>
Choosing "Browse for more..." then launches the search for all servers but
is quite slow depending on the number of servers it searches through on the
network.

Note I was not seeing even my local machine in the list of all servers but
this was due to some strange VPN problem.

Show quote
"Jeff Dillon" wrote:

> Bill, I think he is saying he is getting ALL servers. He just wants to
> enumerate those on the local machine. He is getting these, plus the rest of
> the network, too
>
> Jeff
Author
12 Apr 2006 7:07 PM
William (Bill) Vaughn
Ah. In that case, filter the returned table using a DataView based on the
local machine name...

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Show quote
"Scott" <Sc***@discussions.microsoft.com> wrote in message
news:CF0776D7-0F57-4A1F-9E77-67C175FDC9AF@microsoft.com...
> Jeff and Bill,
>
> Yes, what I would like to be able to do is have initially a list of only
> the
> SQL servers that are local to the machine.
> Similar to the dialog the comes up when running Micorsoft SQL Server
> Management Studio: It's initial dropdown shows (which is very fast):
>    MYMACHINENAME/SQLEXPRESS
>    MYMACHINENAME
>    <Browse for more...>
> Choosing "Browse for more..." then launches the search for all servers but
> is quite slow depending on the number of servers it searches through on
> the
> network.
>
> Note I was not seeing even my local machine in the list of all servers but
> this was due to some strange VPN problem.
>
> "Jeff Dillon" wrote:
>
>> Bill, I think he is saying he is getting ALL servers. He just wants to
>> enumerate those on the local machine. He is getting these, plus the rest
>> of
>> the network, too
>>
>> Jeff
Author
19 Apr 2006 6:09 AM
Thomas Due
William (Bill) Vaughn wrote:

>Ah. In that case, filter the returned table using a DataView based on
>the local machine name...

Look it up in the registry?

--
Thomas Due
Posted with XanaNews version 1.18.1.3

"Victorious warriors win first and then go to war, while defeated
warriors go to war first and then seek to win."
-- Sun-tzu, The Art of War. Strategic Assessments
Author
19 Apr 2006 6:31 AM
William (Bill) Vaughn
See the My and Application classes.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Show quote
"Thomas Due" <tdue@mail_remove_.dk> wrote in message
news:uHwOWf3YGHA.1580@TK2MSFTNGP02.phx.gbl...
> William (Bill) Vaughn wrote:
>
>>Ah. In that case, filter the returned table using a DataView based on
>>the local machine name...
>
> Look it up in the registry?
>
> --
> Thomas Due
> Posted with XanaNews version 1.18.1.3
>
> "Victorious warriors win first and then go to war, while defeated
> warriors go to war first and then seek to win."
> -- Sun-tzu, The Art of War. Strategic Assessments

AddThis Social Bookmark Button