How to get the client IP address from SQL Server 2008 itself?

后端 未结 6 1831
感动是毒
感动是毒 2020-12-05 02:11

I have a trigger for insert/update/delete. That is working fine. Also, I need the client\'s IP address from where the changes are made. That I need in T-SQL, that means, not

6条回答
  •  眼角桃花
    2020-12-05 03:08

    I found something which might work for you

    CREATE FUNCTION [dbo].[GetCurrentIP] ()
    RETURNS varchar(255)
    AS
    BEGIN
        DECLARE @IP_Address varchar(255);
    
        SELECT @IP_Address = client_net_address
        FROM sys.dm_exec_connections
        WHERE Session_id = @@SPID;
    
        Return @IP_Address;
    END
    

    From How to get Client IP Address in SQL Server

    Also have a look at this article about Get client IP address

提交回复
热议问题