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 @   麦麦提敏  阅读(4580)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示