• Please tell me you are using a local/desktop instance of SQL server to run this code and that you're not doing this on a production server.

    I might try to convince you to use a scripting environment for this task and have it contact your database to store the found/discovered data - but I also understand that if your comfort zone is T-SQL that's the language you'll use to solve the problem at hand. (when your only tool is a hammer all your problems look like nails)

    Some other thoughts:

    You're already using dynamic sql, why not make the column name in the table also passed into the procedure - in case the dynamic tablename has some other column name containing the hostnames.

    Try updating your ping command to include -n 1 and -w 1 so you only ping once and only wait 1ms for a reply. Since you are only looking for the dns lookup "Pinging...[a.b.c.d]" line anyway you don't really even need the results of the ping. Sending 1 instead of the default 4 will be less wasteful (and faster) and timing-out quickly (especially on not-found hosts) will also help this task complete sooner. (which might not be important until you consider the resources consumed by executing xp_cmdshell 500+ times in a cursor)

    btw, if you decide to store the IP address using 4 tinyint fields for the sake of indexing and easier grouping by various octets, you can use parsename() for a clever split:

    select parsename('192.168.1.10',4) /* 192, or the "server" part of a 4part name */

    select parsename('192.168.1.10',3) /* 168, or the "database" part of a 4part name */

    select parsename('192.168.1.10',2) /* 1, or the "owner" part of a 4part name */

    select parsename('192.168.1.10',1) /* 10, or the "table" part of a 4part name */