windwos API to list mssql servers in network

  • hi all,

    I found that osql /L would give the list of mssql server instances in the network, but i need a windows API or ODBC method to get it to implement in an application rather than a command mode utility.

  • What is your question?

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • If i need to find all mssql server instances installed in a network,

    I could get this by typing osql /L.

    But i would like to list the names of different mssql server instances

    programatically to implement in an application using WinAPI

  • Not sure. Could you do something like

    osql /L > sqlservers.txt

    to redirect the output to a file called sqlservers.txt and then use that in your app?

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Fine, Thanx

    But then I would appreciate if i could get direct ways

    -deena

  • There is an article on “The Code Project” that may be of use.

    Enumerate SQL Server using SQL DMO

    By Rashid Thadha

    Get a list of SQL Servers to which you can connect.

    http://www.codeproject.com/database/serverenum.asp

  • Hi,

     

    I've got some Delphi code that'll get a list of SQL Servers on your network if you want it.

  • Thanks for everyone those who have replied

    I trying to work thro' SQLBrowseConnect of ODBC.

    regards

    deena

  • Don't think that this list will be authoritative in all cases on all networks. There are lots of reasons why all of the SQL Servers on a network potentially will not show up with "OSQL -L". Here's a few for starters:

    • routing
    • network segmentation
    • switched network
    • firewalls
    • IPsec
    • policy
    • domains
    • trust

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • Have you tried SQL-DMO?  What is your development environment?

  • Whether you use a Windows API, ODBC or SQL DMO the information in my previous post still stands.

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • hi

    I am using ODBC to connect the db with VC++

    I have not tried SQL DMO. Do I able to list the servers without connecting to the server in local machine.

    thanx

    deena

  • Here is sample VB code to display all available SQL servers:

        Dim i As Integer

       

        For i = 1 To SQLDMO.ListAvailableSQLServers.Count

            MsgBox SQLDMO.ListAvailableSQLServers(i)

        Next i

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply