Gets the IP address of the client on which the process is located, based on the process number

Source: Internet
Author: User
IP Address | process | Client CREATE PROCEDURE dbo. Sp_spidtoip @SPID int AS--SPID to MAC--LJ DECLARE @MAC as varchar (a) SELECT @MAC = net_address from master. sysprocesses WHERE SPID = @SPID-MAC to IP DECLARE @MACDisplay as varchar (a) DECLARE @IP as varchar CREATE TABLE #t EMP (OUTPUT varchar (255) NULL) SET NOCOUNT on INSERT into #temp EXEC master. xp_cmdshell ' arp-a ' if @ @error begin RAISERROR (' The level for job_id:%d should is between%d and%d. ', 1)--rollback TRANSACTION end SELECT @MACDisplay = Left (@MAC, 2) + '-' + SUBSTRING (@MAC, 3, 2) + '-' + SUBSTRING (@MAC, 5, 2) + '-' + SU Bstring (@MAC, 7, 2) + '-' + SUBSTRING (@MAC, 9, 2) + '-' + SUBSTRING (@MAC, one, 2) SELECT @IP = SUBSTRING (output, 3,) from #temp WHERE output like '% ' + @MACDisplay + '% '--Resolve the IP--declare @CMD as varchar (MB)--select @CMD = ' master. . xp_cmdshell "Ping-a ' + @IP + '" '--exec (@CMD) DROP TABLE #temp SET NOCOUNT off go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.