Internet Access stored procedures for SQL Server 7.0, 2000, 2005 (Win32) |
Important note
These procedures are implemented in xpFileUtils library.
Overview
This adds to T-SQL access to internet hosts and websites.
There are the following procedures:
xp_IsPortOpen checks (scans) if the host has the given port open;
xp_GetAddrByHost returns the IP address for the given host name;
xp_GetHostByAddr returns the host name for the given IP address;
xp_Ping returns statistics of ping operation like ping.exe utility does;
xp_CanPing only checks if the destination host can be pinged (e.g. reachable);
xp_TraceRoute returns statistics of trace route operation like tracert.exe utility does.
xp_Whois on the given internet address, performs requests to international WHOIS databases and returns any available registration data;
Example
Check if the host address ('localhost') is available using default parameters (3000 ms timeout, 4 attempts):
declare @result int
exec @result = master..xp_CanPing 'localhost'
if @result = 1
print 'The destination host is available'
else
if @result = 0
print 'The destination host is unavailable'
else
print 'Network failure'