List all SQL servers on network

Hello,
I'm trying to find a way to produce a list of all the SQL servers running on a network and have been looking at the SQLDataSourceEnumerator GetDataSources method. However there is a note saying this may not show all the SQL servers and may return a different list each time it is called. I would be grateful if anyone has anymore information on why this will not always return a complete list and may be different each time or if anyone knows if there is a way I can get a list of SQL servers that is more consistent?
Thanks,
Caroline

u can execute this code
Set NoCount On
Declare @CurrID int,@ExistValue int, @MaxID int, @SQL nvarchar(1000)
Declare @TCPPorts Table (PortType nvarchar(180), Port int)
Declare @SQLInstances Table (InstanceID int identity(1, 1) not null primary key,
                                          InstName nvarchar(180),
                                          Folder nvarchar(50),
                                          StaticPort int null,
                                          DynamicPort int null,
                                          Platform int null);
Declare @Plat Table (Id int,Name varchar(180),InternalValue varchar(50), Charactervalue varchar (50))
Declare @Platform varchar(100)
Insert into @Plat exec xp_msver platform
select @Platform = (select 1 from @plat where charactervalue like '%86%')
If @Platform is NULL
Begin
Insert Into @SQLInstances (InstName, Folder)
Exec xp_regenumvalues N'HKEY_LOCAL_MACHINE',
                             N'SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL';
Update @SQLInstances set Platform=64
End
else
Begin
Insert Into @SQLInstances (InstName, Folder)
Exec xp_regenumvalues N'HKEY_LOCAL_MACHINE',
                             N'SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL';
Update @SQLInstances Set Platform=32
End  
Declare @Keyexist Table (Keyexist int)
Insert into @Keyexist
Exec xp_regread'HKEY_LOCAL_MACHINE',
                              N'SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\Instance Names\SQL';
select @ExistValue= Keyexist from @Keyexist
If @ExistValue=1
Insert Into @SQLInstances (InstName, Folder)
Exec xp_regenumvalues N'HKEY_LOCAL_MACHINE',
                              N'SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\Instance Names\SQL';
Update @SQLInstances Set Platform =32 where Platform is NULL
Select @MaxID = MAX(InstanceID), @CurrID = 1
From @SQLInstances
While @CurrID <= @MaxID
  Begin
      Delete From @TCPPorts
      Select @SQL = 'Exec xp_instance_regread N''HKEY_LOCAL_MACHINE'',
                              N''SOFTWARE\Microsoft\\Microsoft SQL Server\' + Folder + '\MSSQLServer\SuperSocketNetLib\Tcp\IPAll'',
                              N''TCPDynamicPorts'''
      From @SQLInstances
      Where InstanceID = @CurrID
      Insert Into @TCPPorts
      Exec sp_executesql @SQL
      Select @SQL = 'Exec xp_instance_regread N''HKEY_LOCAL_MACHINE'',
                              N''SOFTWARE\Microsoft\\Microsoft SQL Server\' + Folder + '\MSSQLServer\SuperSocketNetLib\Tcp\IPAll'',
                              N''TCPPort'''
      From @SQLInstances
      Where InstanceID = @CurrID
      Insert Into @TCPPorts
      Exec sp_executesql @SQL
      Select @SQL = 'Exec xp_instance_regread N''HKEY_LOCAL_MACHINE'',
                              N''SOFTWARE\Wow6432Node\Microsoft\\Microsoft SQL Server\' + Folder + '\MSSQLServer\SuperSocketNetLib\Tcp\IPAll'',
                              N''TCPDynamicPorts'''
      From @SQLInstances
      Where InstanceID = @CurrID
      Insert Into @TCPPorts
      Exec sp_executesql @SQL
      Select @SQL = 'Exec xp_instance_regread N''HKEY_LOCAL_MACHINE'',
                              N''SOFTWARE\Wow6432Node\Microsoft\\Microsoft SQL Server\' + Folder + '\MSSQLServer\SuperSocketNetLib\Tcp\IPAll'',
                              N''TCPPort'''
      From @SQLInstances
      Where InstanceID = @CurrID
      Insert Into @TCPPorts
      Exec sp_executesql @SQL
      Update SI
      Set StaticPort = P.Port,
            DynamicPort = DP.Port
      From @SQLInstances SI
      Inner Join @TCPPorts DP On DP.PortType = 'TCPDynamicPorts'
      Inner Join @TCPPorts P On P.PortType = 'TCPPort'
      Where InstanceID = @CurrID;
      Set @CurrID = @CurrID + 1
  End
Select serverproperty('ComputerNamePhysicalNetBIOS') as ServerName, InstName, StaticPort, DynamicPort,Platform
From @SQLInstances
Set NoCount Off

Similar Messages

  • How do i get a list of SQL Servers from network?

    Hi everyone,
    I'm trying to get a list of SQL Servers from the network and put them into a drop-down combo box. I try to search on Google and i can only find some C# source codes which doesn't help me at all. I'm wondering if JAVA has the similar method to do so.
    btw, I'm using MSSQL Server 2005, JDBC 1.2, JDK 1.6.0_24
    thanks

    jschell wrote:
    flyto9 wrote:
    I'd been told to create a user friendly no brainer user interface In typical business scenarios involving databases that is ridiculous.
    A company that has multiple database servers must ALREADY understand the complexities of managing and using those databases.
    true, but you know as well as I do that requirements documents are usually not written by people with the least understanding on those complexities...
    And if a company assigns such a project to someone like OP who clearly doesn't know how to deal with such requirements documents, that only shows their morosity all the more clearly :)
    Assuming that I'm able to find a list of TCP connections on network, how do I know which of them are sqlserver?That isn't what I said. A "protocol" is a description of a methodology involving functionality and communication which solves a particular problem.
    There is a "protocol" which describes how to find MS SQL Servers. You don't make it up yourself. You find the description, read what it says and implement it.Or more likely (like Oracle) there's no such security problem in MS SQL Server and instead it relies on the client knowing the connection details or it'll never find them.

  • Cannot list all the servers within cluster (on Resin)

    We have 10 Resin servers in the cluster, but when I try to list them I got only 9 of them listed.
    It doesn't list the local server (the one from which the servlet is actually invoked).
    Do you have any other idea how to list all the servers?
    Here is the code I use:
    for (int i = 0; i < clusterList.length; i++) {
         ClusterMXBean cluster = (ClusterMXBean) Jmx.findGlobal(clusterList.getObjectName());
         // --- retrieve all servers within one cluster
         ServerConnectorMXBean[] srunNames = cluster.getServers();
         for (int j = 0; j < srunNames.length; j++) {
              ServerConnectorMXBean server = (ServerConnectorMXBean) Jmx
                        .findGlobal(srunNames[j].getObjectName());
              String host = server.getAddress();
              int port = server.getPort();
              String state = server.getState();
    And here is the MX configuration:
    resin:type=SessionManager,Host=default,WebApp=/
    resin:type=ServerConnector,name=i
    resin:type=ServerConnector,name=h
    resin:type=ServerConnector,name=b
    resin:type=Resin
    resin:type=ServerConnector,name=j
    resin:type=ProxyCache
    resin:type=Host,name=default
    resin:type=ServerConnector,name=c
    resin:type=ServerConnector,name=e
    resin:type=Port,name=192.68.1.50-6802
    resin:type=ServerConnector,name=g
    resin:type=ServerConnector,name=a
    resin:type=ThreadPool
    resin:type=WebApp,Host=default,name=/
    resin:type=WebApp,Host=default,name=/mya
    resin:type=ConnectionPool,Host=default,WebApp=/mya,name=jdbc/mya
    resin:type=ServerConnector,name=f
    resin:type=Cluster,name=cluster1
    resin:type=ServerConnector,name=d
    resin:type=SessionManager,Host=default,WebApp=/mya
    resin:type=Server                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    kus wrote:
    There is a solution but not a very portable one, i.e. you can't use it to get a listing of files from any server that you happen to look at. But here are the steps you need to take:
    1. Use a browser (firefox, opera, etc.) to view the file listing and then view the source.
    2. Duplicate the retrieval of data from the given URL in Java (new URL(...), etc.)
    3. Parse the HTTP response and/or the HTML that the server returns to you to extract what you need.
    Step #3 is the biggest piece of work and the format you need to parse will depend on whatever the remote server hands to you. It's intended for humans, not machines; every server can decide how to format this and it even depends on the server's configuration how this data is presented to you. In any case, it's entirely up to you to make sense of whatever the server happens to throw back at you and if the server happens to present you a nice, picturesque page rather than a listing of files then your completely out of luck.He actually wasn't talking about http at all, so most of this thread has been a wild goose chase.

  • List all DNS servers in an AD Forest

    Is there a way (preferably powershell, of course!) to find all DNS servers in an AD forest?  Not domain controllers running DNS but ANY Windows servers running DNS.
    Here is the situation...I have one root domain to which I am adding a new domain controller.  There are roughly 20 child domains which should all have their dns servers set to forward to my root domain for unresolved queries.  I need to change the forwarders on all DNS servers in the Forest (I've got that part figured out).  However, I know that not all Domain Controllers in all of the domains are DNS servers and vice versa (not all DNS servers in the domains are domain controllers).
    So...anything that I can query to find all dns servers in the Forest (short of querying every server in the Forest for the existence of the DNS Server service?)
    I've searched but can't seem to find anything in wmi.
    Thanks,
    Nate

    That would just list all DCs within a domain (not even in the entire forest).
    You can use DNSLint (http://support.microsoft.com/kb/321045) or dnscmd (assuming you’re hosting your AD DNS Zones on Microsoft DNS Servers) to query for
    NS records.
    Regards
    Christoffer Andersson – Principal Advisor
    Enfo Zipper
    "EXRAPUL" wrote in message news:ea6d0f00-0bc0-4786-b63b-c618e51ff264...
    Hi Nate,
    Yes, we can find list of DNS servers by using a command "nltest".
    Here is the syntax nltest/dnsgetdc:<forest name>
    example: nltest/dnsgetdc:microsoft.com
    Enfo Zipper Christoffer Andersson – Principal Advisor

  • I want to list all of my wifi networks

    Hello all, I would like to find out all of the wifi networks that my iphone has been connected to. How can I list these networks?
    Thanks.
    Kevin

    No such feature exists in iOS.    

  • Getting all SQL servers in one dynamic group

    Since the release of the SQL 2014 MP there are now 2 SQL server MP's, 1 just for 2014 and one that covers 2005,2008 & 2012. Does anyone know a way to create a dynamic group that includes all servers that have any SQL install on?

    Hi,
    Look at these posts:
    http://scug.be/jan/2013/01/23/scom-excluding-items-from-a-group-based-on-hosted-roles/
    http://blog.tyang.org/2015/01/18/creating-opsmgr-instance-group-computers-running-application-health-service-watchers/
    Natalya
    ### If my post helped you, please take a moment to Vote as Helpful and\or Mark as an Answer

  • List all computer names on network

    Our former router would display: computer name, IP address, and MAC address.  Here, you can see that our "new and improved" router (issued by our benevolent ISP) only displays IP and MAC.  I was just wondering if there were any ways for me to display computer names to better assess if any unauthorized users are leeching onto our network.
    One quasi-solution was the command:
    sudo nbtscan -r 192.168.0.1/24
    However, it only shows Windows client names, and only some of the time (for instance, it isn't displaying a roommate's laptop name, even though his laptop is online and running Windows).

    ewaller wrote:Have you looked at Avahi?
    This may just prove to be the philosopher's stone for which I've sought   However, when I run the command to view network hosts, it only displays one, my roommate's Chromecast, and just kinda idles on that (I've redacted the username and IP):
    root@Sera:~# avahi-browse -alr
    + eth0 IPv4 Username Chromecast _googlecast._tcp local
    = eth0 IPv4 Username Chromecast _googlecast._tcp local
    hostname = [Username\032Chromecast.local]
    address = [192.168.x.xx]
    port = [8009]
    txt = ["ic=/setup/icon.png" "md=Chromecast" "ve=02" "id=ed346d0f9965c73d2328545b8f55166e"]
    EDIT: I seemed to have missed the part about avahi-browse detecting computers with Avahi installed :\  So, that might explain why most of the computers on the network aren't showing up -- although it doesn't explain why Chromecast shows up. 
    Here's a screenshot of our old router, which shows the names of connected users.  I'd think it wouldn't be so hard to implement this on a 'newer' router.
    Last edited by apolyonn (2014-02-17 03:28:21)

  • How to fill combo box with list of all SQL server

    Ok, I know how to find all SQL servers that I need, I have code for that task, and I have Array of all servers.
    My problem is ...
    I made setup project and do a huge work, and in the end this task appear!
    I used ORCA tool to change TextBox (A) template in visual studio (2008 by the way), and I transform first TextBox to ComboBox.
    Now, the little part that I'am missing is how to fill this combo box with a result of my function for listin SQL servers?
    Can I somehow send combobox object to myMethod:
    private void FillCombo(ComboBox cmb)
          // do the job
    or
    instanceOfThisCombo.Items.Add(listOfSQLServers);
    please help me to solve this... thanksc#

    Hi Valerij,
    The ComboBox control in an MSI dialog uses the ComboBox table to populate the items in it. To get what you want, you need to update the ComboBox table in the MSI package with your application and run the MSI package. The following KB article describes how to dynamically populate a ListBox control in Windows Installer:
    http://support.microsoft.com/kb/291329
    This method introduced in the above KB article also applies to populating a ComboBox control in Windows Installer.
    I don't think it's possible to run the application as a Custom Action from within the MSI package because the application will modify the content of the MSI package which is currently running. So you need to launch the MSI package from within your application after updating the ComboBox table. In short, when installing, just run your application which updates the ComboBox table and install the MSI package.
    Hope this helps.
    If you have any question, please feel free to let me know.
    Sincerely,
    Linda Liu

  • Dynamic Group Membership - All SQL Computers in a Domain

    I am trying to create groups containing all SQL servers in each domain. I am using the Wizard in the console. However I appear to be having winter blues as I can't work out how to do it. Everything I try results in an empty group.
    Can someone please explain what I need to do to?

    Roger
    Thanks for the input. The code looks logical and I applied it and imported a revised MP. However I am not getting any membership in the group. There is another group membership in the same MP and that populates correctly, so I haven't a clue where I'm going
    wrong. As you can see below my rule is the same as yours, except with a different domain name.
    <Expression>
                 <And>
                              <Expression>
                                           <RegExExpression>
    <ValueExpression>
    <Property>$MPElement[Name="MicrosoftWindowsLibrary7585010!Microsoft.Windows.Computer"]/NetbiosDomainName$</Property>
    </ValueExpression>
    <Operator>ContainsSubstring</Operator>
    <Pattern>DOMAINNAME</Pattern>
                                           </RegExExpression>
                              </Expression>
                              <Expression>
                                           <Contained>
    <MonitoringClass>$MPElement[Name="MicrosoftSQLServerLibrary6410!Microsoft.SQLServer.ComputerGroup"]$</MonitoringClass>
                                           </Contained>
                              </Expression>
                 </And>
    </Expression>
    Eric

  • Script to list all servers in my domain

    i need to list all the windows servers in my organization so i was wondering if anyone knew of or had a script that could do this and export it to a csv file.

    You don't need a script.  You just need to list servers from the computer browse list.  This can be done with
    Net View or the Browstat commands. 
    browstat vw 1 | find /i ",SS" will list just the servers.  With the browstat output there are several items you can easily search for, Version, DFS, SQL, etc.
    \\Servername   NT   05.02 (W,S,SQL,NT,SS,BBR,DFS)
    Use quick edit/Mark and copy in the command prompt to select and copy only the server names out as needed.
    Using the browse list is actually a better method because it shows you only active servers.  While obtaining a list from Active Directory will have old server accounts listed.
    http://support.microsoft.com/kb/818092

  • How can I list all the domains configured for Weblogic Servers?

    How can I list all the domains configured for Weblogic Servers?
    I saw a note, which says the following:
    "WebLogic Server does not support multi-domain interaction using either the Administration Console, the weblogic.Admin utility, or WebLogic Ant tasks. This restriction does not, however, explicitly preclude a user written Java application from accessing multiple domains simultaneously."
    In my case, I just want to list all the domains, is that possible by using any scripts?
    Thanks
    AJ

    If you use WLS Node Manager and the Config Wizard was used to create the domains, then the list of domains should be in a location like this:
    <MIDDLEWARE_HOME>\wlserver_10.3\common\nodemanager\nodemanager.domains
    Enterprise Manager Grid Control also has support for multi-domain management of WLS in a console.

  • List all servers with OS and service pack

    Is there an easy way using any script or software to list all servers joined to your domain including operating system (i.e. server 2008) and service pack level, without having to check each manually?

    Hi Cf090,
    The limit is used to Specify the number of objects to return that matches the criteria that you specify. If you specify a value of
    0 for <NumberOfObjects>, this parameter returns all matching objects. If you do not specify this parameter,
    dsquery displays the first 100 results by default.
    For more detailed information to use dsquery, please refer to this article:
    http://technet.microsoft.com/en-us/library/cc754232.aspx
    If you have any other questions, please feel free to let me know.
    Best Regards,
    Anna

  • Help: SQL list all duplicate records

    Given table B with employer_id, ssn, period and employee_name, list all records with duplicate ssn for a given period and employer_id.
    I used:
    select employer_id, ssn, employee_name, count(ssn) from B
    group by employer_id, ssn
    where period='xxx' and count(ssn)>1
    got error:
    ORA-00933: SQL command not properly ended
    checked sometime and still can not figure it out, any help will be greatly appreciated.

    select employer_id, ssn, employee_name, count(ssn) from B
    where period='xxx'
    group by employer_id, ssn,employee_name having count(ssn)>1
    Regards
    Helio Dias
    http://heliodias.com

  • PLEASE SEND ME SQL query to list ALL CONSTRAINTS ON EMPLOYEES TABLE FROM OU

    PLEASE SEND ME SQL query to list ALL CONSTRAINTS ON EMPLOYEES TABLE FROM OUTSIDE PP SCHEMA INCLUDING SCHEMA NAME AND CONSTraint NAME
    Username : PP
    Table : Employees

    I think you are looking for below query :
    SQL> SHOW USER;
    USER is "SCOTT"
    SQL> select owner,constraint_name,constraint_type,table_name,r_owner,r_constraint_name
      2    from all_constraints
      3    where constraint_type='R'
      4   and r_constraint_name in (select constraint_name from all_constraints
      5    where constraint_type in ('P','U') and table_name='EMP');
    OWNER                          CONSTRAINT_NAME                C TABLE_NAME                     R_OWNER                        R_CONSTRAINT_NAME
    TEST1                          ERL_EMP_FK_1                   R EMPLOYEE                       SCOTT                          PK_EMP
    1 row selected.Means, TEST1 user is having a constraint ERL_EMP_FK_1 on his table EMPLOYEE. Which is using PK_EMP (primary key of SCOTT user's 'EMP' [in the query])
    Regards
    Girish Sharma

  • SQL query to list all collections, members, OS, SP, IP and if physical/virtual

    Hi guys, I have the below query which lists all the collections and their members, however I need to expand it to also include the OS, Service Pack, IP and if it's a physical or virtual machine.
    I've tried a few things but only made it worse. Is anyone able to expand the below code to include those extras??
    SELECT
    v_FullCollectionMembership.CollectionID AS 'CollID',
    v_Collection.Name AS 'CollName',
    v_FullCollectionMembership.Name AS 'SystemName'
    FROM
    v_FullCollectionMembership, v_Collection
    WHERE v_FullCollectionMembership.CollectionID = v_Collection.CollectionID
    ORDER BY
    CollID ASC, SystemName ASC

    Hi,
    These requirements could be found in several threads or blogs. We need convert WQL to SQL, and you can involve SQL guys to integrate the statements and format the result.
    How to create a all virtual machines collection.
    SCCM SQL Query - IP Address
    ConfigMgr Systems without Current Service Packs, and System Patch Status 

Maybe you are looking for

  • Windows XP 2005 Edition?

    I was thinking of installing the Windows XP 2005 Media Centre Edition, however I've just been looking at the Boot Camp manuals, and here's what one part of it says: 'A licensed copy of Windows XP Home Edition or Professional, or Windows Vista Home Ba

  • I can't have my own personal data without a judge seeing it first!

    I have been a Verizon customer since October of 2009. For the most part, I've enjoyed your services. You have extremely helpful customer service representatives both at your stores and through your call center. I didn't even mind when you took away u

  • Is there a way to insert AFDs into a file upon export?

    I don't *think* this is possible, but I wanted to get confirmation.  Can Premiere insert an AFD flag to a file upon export?

  • Error occouring when i download free video downloader

    i go to tools option in top of page i write fvd in search option some results come after i click instal after some seconds it shows error i have tried re installing Mozilla but it didn't worked

  • Problems with datatable and scroller

    I wonder, if this behavior is a mistake of mine or a bug in the myfaces implementation. sitution I have datatable and datascroller component. The table gets the data from bean which is in request scope. The table is dynamic. Each time we hit the page