views:

257

answers:

1

Hi, I wanted to know if we can retrieve IPAddresses of any machine (can be local or remote) via Microsoft SQL Stored Procedure WITHOUT using INSERT EXECUTE.

+2  A: 

All you need as a starting point is:

SELECT client_net_address, local_net_address FROM sys.dm_exec_connections

Obviously, it needs a bit more work but sys.dm_exec_connections has both server and client IP addresses.

Edit:

I suggest you look at CLR code fi you want to gather information that SQL Server simply does not have within your restrictions.

Any pure T-SQL solution requires running a stored proc such as xp_cmdshell which requires INSERT EXEC.

A parameterised stored proc would have to be custom extended one to avoid INSERT EXEC.

gbn
This seems to give IP address of only machines that are accessing the particular SQL instance. I wanted to say "any machine" on the network which may not be necessarily accessing the SQL server (similar to ping machine name).
Ganesh R.
OK, I updated the question.
gbn
I thought of CLR option. However I need to support SQL 2000 too. Hence it is out of question. Also openrowset was a possible workaround.
Ganesh R.
Don't know how you'd use openrowset
gbn