Fetch IP address in query/job

  • Hi,

    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.

     

  • 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.

    John

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

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