Fetch IP address in query/job

  • haichells


    Points: 2698


    I am trying to fetch IP address of the SQL Server through Query with below commands and it is working fine. But when I add it in a job it is not fetching/showing the IP. Please help.

    Select cONVERT(VARCHAR,CONNECTIONPROPERTY('local_net_address') )

    select local_net_address FROM sys.dm_exec_connections WHERE SESSION_ID = @@SPID

    Problem is when i run this in a job and assign it to a variable it is not showing the IP.


  • John Mitchell-245523

    SSC Guru

    Points: 148652

    A SQL Server Agent job runs automatically, not interactively, so where are you expecting the value to show?  If you want to record it in a table, just use an INSERT statement.


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

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