Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL
Expertise: Advanced
Jan 20, 2004

Get Details of the Aggregated Data

Say you want to get the latest processes running on Microsoft® SQL Server and their time, hostname, and the username. The following query retrieves this data:

Use Master
Select SysPro1.program_name,
SysPro1.login_time,SysPro1.MemUsage,SysPro1.Hostname,SysPro1.Hostname,SysP
ro1.nt_domain,SysPro1.nt_username
From sysprocesses SysPro1
INNER JOIN

(SELECT program_name, MAX(login_time) as T2
FROM sysprocesses
GROUP BY program_name Having len(program_name) > 0)  SysPro2
ON
( SysPro2.program_name = SysPro1.program_name
  AND
 SysPro2.T2 = SysPro1.login_time )
Dinesh Asanka
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap