Using info on the registered servers

  • I use SQL 2005 client tools to connect SQL Servers by registering them.

    My question is:

    Is there any place I can retrieve their IPs in a script?

    Many thanks for any input in advance

  • you can run this script on each server

    make sure xp_cmdshell is turned on

    --------------------------------------------------------

    SET nocount ON

    DECLARE @ip VARCHAR(15)

    CREATE TABLE #ip (line VARCHAR(255))

    INSERT #ip

    EXEC master.dbo.xp_cmdshell 'ipconfig'

    DELETE #ip

    WHERE Charindex('IP Address',line) <= 0

    DELETE #ip

    WHERE line IS NULL

    SELECT @ip = Substring(line,Charindex(':',line) + 1,255)

    FROM #ip

    SELECT REPLACE(Ltrim(Rtrim(REPLACE(line,'IP Address. . . . . . . . . . . . :',

    ''))),CHAR(13),'') AS 'IP Addresses'

    FROM #ip WITH (nolock)

    DROP TABLE #ip

    ----------------------------------------------------

    Alex S

Viewing 2 posts - 1 through 2 (of 2 total)

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