Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Help writing report to determine active users?

Author  Topic 

DBADave
Constraint Violating Yak Guru

366 Posts

Posted - 2003-06-02 : 11:40:49
Any suggestions on how to create a report to show when someone first connected to SQL Server and when they last processed anything on SQL Server?

I wrote a query to check sysprocesses every 10 minutes, but it only reports that the person has a connection. It does not tell me if the connection is active. I thought I may need to look at processor and disk to see if those numbers change, but I'm not sure if that is the best approach. Any thoughts?

Thanks, Dave

Shastryv
Posting Yak Master

145 Posts

Posted - 2003-06-02 : 12:44:13
The Best is laughing a Trace, but this gives you unnecessary data too. If you are running SQL 7.0 you can use the following one

Exec xp_sqltrace Trace, @EventFilter = 115, @Fulltext = 1

Or you can test your T-SQL skill modifying the following SP to your requirements

SELECT
DATEDIFF(day, last_batch, getdate()) AS Days,
sp.spid,
sp.nt_username as NTname,
sp.loginame,
sp.hostname,
sp.program_name,
sd.name as DBName,
sp.login_time,
sp.last_batch,
sp.status,
sp.dbid,
sp.cmd,
sp.lastwaittype

FROM master..sysdatabases sd RIGHT OUTER JOIN
master..sysprocesses sp ON sd.dbid = sp.dbid
and sd.name is not null


Go to Top of Page
   

- Advertisement -