KSOA单据保护表中Clientid解析为mac和ip
作者:互联网
SELECT DISTINCT a.*,ISNULL(c.client_net_address,'') AS client_net_address FROM ( SELECT * ,RIGHT(UPPER(sys.fn_varbintohexstr(CONVERT(VARBINARY(4),CAST(SUBSTRING(clientid,1,3) AS INT)))),2) +RIGHT(UPPER(sys.fn_varbintohexstr(CONVERT(VARBINARY(4),CAST(SUBSTRING(clientid,4,3) AS INT)))),2) +RIGHT(UPPER(sys.fn_varbintohexstr(CONVERT(VARBINARY(4),CAST(SUBSTRING(clientid,7,3) AS INT)))),2) +RIGHT(UPPER(sys.fn_varbintohexstr(CONVERT(VARBINARY(4),CAST(SUBSTRING(clientid,10,3) AS INT)))),2) +RIGHT(UPPER(sys.fn_varbintohexstr(CONVERT(VARBINARY(4),CAST(SUBSTRING(clientid,13,3) AS INT)))),2) +RIGHT(UPPER(sys.fn_varbintohexstr(CONVERT(VARBINARY(4),CAST(SUBSTRING(clientid,16,3) AS INT)))),2) AS MAC FROM tmp_dj_baohu ) AS a LEFT JOIN sys.sysprocesses AS b ON a.MAC = b.net_address LEFT JOIN sys.dm_exec_connections AS c ON b.spid = c.session_id
标签:SUBSTRING,CONVERT,varbintohexstr,ip,Clientid,sys,mac,clientid,VARBINARY 来源: https://www.cnblogs.com/jijm123/p/10382274.html