SQL instances PowerBASIC Peer Support Community (original) (raw)

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