查看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

猜你喜欢

转载自www.cnblogs.com/linybo/p/10092563.html