You are here: Re: SQL Server License Control and Management « MsSQL Server « IT news, forums, messages
Re: SQL Server License Control and Management

Posted by Luukkanen Tapio on 03/22/06 14:41

Maybe you could periodically select stuff from master.db.sysprocesses, and
count the number of distinct remote client workstation names or number
of distinct client user names over some suitable period?

-tapio

Something developed out of the following might give a guess of the
number of distinct "real users" you have?
Of course this needs changes if you use sqlserver security.

if not exists (select 1 from sysobjects
where name = 'connstats' and type='U')
begin
create table connstats (
client varchar(20)
,ntuser varchar(20)
,program varchar(40)
,dbname varchar(20)
,ts datetime
)
end
go

if exists (select 1 from sysobjects
where name = 'dbu_gather_stats' and type='p')
drop procedure dbu_gather_stats
go

create procedure DBU_gather_stats
as
begin
insert into connstats(client, ntuser, program, dbname, ts)
select p.hostname, p.nt_username, p.program_name
,d.name, getdate()
from master.dbo.sysprocesses as p
,master.dbo.sysdatabases as d
where p.dbid = d.dbid
end
go

grant execute on DBU_gather_stats to public
go

if exists (select 1 from sysobjects
where name = 'dbu_stats' and type='p')
drop procedure dbu_stats
go
create procedure DBU_stats
as
begin
select
"date"=substring(convert(varchar,ts,126),1,10)
,"clients"=count(distinct client)
,"users"=count(distinct ntuser)
,"programs"=count(distinct program)
from master..connstats
group by
substring(convert(varchar,ts,126),1,10)
end
go

grant execute on DBU_stats to public
go

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация