From this post you can learn how to find the process id for all running instance in the sql server.
In this post you can learn how to find the process id for all running instance in the sql server.
--Running connections
DECLARE @SPWHO2 TABLE
(
SPID VARCHAR(1000),
[Status] VARCHAR(1000) NULL,
[Login] VARCHAR(1000) NULL,
HostName VARCHAR(1000) NULL,
BlkBy VARCHAR(1000) NULL,
DBName VARCHAR(1000) NULL,
Command VARCHAR(1000) NULL,
CPUTime VARCHAR(1000) NULL,
DiskIO VARCHAR(1000) NULL,
LastBatch VARCHAR(1000) NULL,
ProgramName VARCHAR(1000) NULL,
SPID2 VARCHAR(1000) NULL,
Request VARCHAR(1000) NULL
)
INSERT INTO @SPWHO2
EXEC sp_who2
SELECT * FROM @SPWHO2
when you run the above query you will get the process id for all running instance. we are using here sp_who2 and collect that data in a dynamic table.
In this post you can learn how to find the process id for all running instance in the sql server.