Announcement

Collapse
No announcement yet.

SQL instances

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SQL instances

    Is there a API call to get a list of SQL servers instances?

    I am currently using the .NET function with powershell:
    SHELL ("Powershell.exe ""[System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources() | Out-File -encoding ascii .\SrvInstanceOutput.txt"", 0)
    "Similar to SQLCMD -L" but whitout the need of SQLCMD.exe and needed DLL.
    I then check the size of ".\SrvInstanceOutput.txt" to determine my success, but I am sure that there is a better way of doing this.

    I am aware of the register keys/values in "SOFTWARE\Microsoft\Microsoft SQL Serve" but, reading them is only available on the actual SQL server.

    Can I achieve this through the the ODBC driver or a direct API call to the SQL server?

    /Mikael

  • #2
    Instances on a local machine, specific server or available on a network?
    Installed instances or running instances?

    Comment


    • #3
      Hi Stuart, available on network, /Mikael

      Comment


      • #4
        The answer to your main questions is - not as far as I know

        However there is sufficient info at this page to write a simple routine to do it:

        https://www.codeproject.com/Articles...-local-network

        It's just a matter of broadcasting one byte on port 1434 using UDP and a simple task of parsing the text in any responses.

        Comment


        • #5
          Thanks Stuart, I will dive more into the routine described in your supplied link,
          Last edited by Mikael T; 13 May 2021, 04:24 AM.

          Comment

          Working...
          X