Feed on
Subscription

Get this process to be in the Ip address that the client carries according to process date

Create PROCEDURE Dbo.SP_SPIDtoIP @SPID Int
AS
- - SPID To MAC
- - Lj
DECLARE @MAC As Varchar(12)
SELECT @MAC = NET_ADDRESS FROM Master. .sysprocesses WHERE SPID = @SPID
- - MAC To IP
DECLARE @MACDisplay As Varchar(18)
DECLARE @IP As Varchar(15)
CREATE TABLE #temp (OUTPUT Varchar(255) Null)
SET NOCOUNT ON
INSERT INTO #temp EXEC Master. .xp_cmdshell 'arp -a'If @@error%26lt;%26gt;0Begin
RAISERROR ('The Level For Job_id:%D Should Be Between %d And %d. ' , 16, 1)
- - ROLLBACK TRANSACTIONEnd
SELECT @MACDisplay = LEFT(@MAC, 2) + '-' + SUBSTRING(@MAC, 3, 2) + '-' + SUBSTRING(@MAC, 5, 2) + '-' + SUBSTRING(@MAC, 7, 2) + '-' + SUBSTRING(@MAC, 9, 2) + '-' + SUBSTRING(@MAC, 11, 2) SELECT @IP = SUBSTRING(output, 3, 15) FROM #temp WHERE Output LIKE '%' + @MACDisplay + '%'
- - Resolve The IP
- - DECLARE @CMD As Varchar(100)
- - Select @CMD = 'master. .xp_cmdshell "ping -a ' + @IP + '"'
- - Exec (@CMD)
DROP TABLE #temp
SET NOCOUNT OFF
GO

Related:

收藏到网摘:

Submit: