1. 程式人生 > >檢視db連線數sql

檢視db連線數sql

/****** Object:  StoredProcedure [dbo].[SP_Conn]    Script Date: 12/09/2018 19:03:28 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

Create Proc [dbo].[SP_Conn]
as
select count(spid) as counts, 
status, 
hostname, 
dbname = case when dbid = 0 then null when dbid <> 0 then db_name
(dbid) end from master.dbo.sysprocesses where spid >=0 and spid <= 99999 and db_name(dbid)='jjfx' group by status,hostname, case when dbid = 0 then null when dbid <> 0 then db_name(dbid) end GO