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
2009-07-22 10:56:57
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.
2009-07-22 12:13:12
OK, I updated the question.
gbn
2009-07-22 12:23:55
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.
2009-07-24 17:18:01
Don't know how you'd use openrowset
gbn
2009-07-24 19:11:55