文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>SQL 记录数据库连接数信息

SQL 记录数据库连接数信息

时间:2011-01-27  来源:kitesky

从master.dbo.sysprocesses取连接数信息并记录的SQL。

-- create connection_log
create table connection_log
(
time datetime,
date datetime,
hour int,
minute int,
second int,
dbname varchar(56),
connect_count int
)

-- catch data
set nocount on
declare @v_time datetime
while 1=1
begin
select @v_time = GETDATE()
select
@v_time as time,
convert(varchar(10), @v_time, 120) as date,
DATEPART(hour, @v_time) as hour,
DATEPART(minute, @v_time) as minute,
DATEPART(second, @v_time) as second,
DB_NAME(dbid) as datasbase,
count(*) as connect_count
from master.dbo.sysprocesses
where dbid <> 0
group by dbid

waitfor delay '00:00:01'
end

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载