Find all SQL Server instances on local nework

前端 未结 2 1374
闹比i
闹比i 2021-01-16 19:52

I am trying to get all available SQL Server to name with their instance name, I am able to find all available SQL Server names on a local LAN but I am unable to find their i

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-16 20:32

    There are lots of reasons why this call would fail in full or partially.

    From MSDN:

    The list can vary depending on factors such as timeouts and network traffic. This can cause the list to be different on two consecutive calls. Only servers on the same network will be listed. Broadcast packets typically won't traverse routers, which is why you may not see a server listed, but it will be stable across calls. Listed servers may or may not have additional information such as IsClustered and version. This is dependent on how the list was obtained. Servers listed through the SQL Server browser service will have more details than those found through the Windows infrastructure, which will list only the name.

    Server enumeration is only available when running in full-trust. Assemblies running in a partially-trusted environment will not be able to use it, even if they have the SqlClientPermission Code Access Security (CAS) permission. SQL Server provides information for the SqlDataSourceEnumerator through the use of an external Windows service named SQL Browser. This service is enabled by default, but administrators may turn it off or disable it, making the server instance invisible to this class.

    As @Orlando notes this may give you some solutions:

    Find all instances of sql server programmatically

提交回复
热议问题