sql查看本机IP地址

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
GO

-- RUN 
SELECT dbo.GetCurrentIP ()

 

SELECT CONNECTIONPROPERTY('local_net_address') AS 服务端IP地址,
               CONNECTIONPROPERTY('local_tcp_port') AS 服务端口,
               CONNECTIONPROPERTY('client_net_address') AS 客户端IP地址

 

select @@SERVERNAME

select HOST_NAME()

 

posted @ 2018-08-08 13:21  麦麦提敏  阅读(4577)  评论(0编辑  收藏  举报