Wednesday, March 25, 2009

SQL Query to Find Which Users are using which SQL Application

You can use Query below to find which user is using which SQL Application.

SQL Query:

Use Master

SP.SpId 'Session ID',

SP.Nt_UserName UserName,

SD.Name DatbaseName,

SP.LogiName LoginId,

SP.Program_Name App

From Sys.SysProcesses SP

Join Sys.SysDatabases SD on SP.DbId = SD.DbId

Where SP.Nt_UserName Not In ('sa', 'System')

And (SP.loginame <> 'sa')

Order By SpId

No comments:

Post a Comment

span.fullpost {display:inline;}