Advertisement
bluebunny72

Current Users List

Apr 29th, 2015
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.46 KB | None | 0 0
  1. SELECT ci.UserName
  2. ,ISNULL(un.UserDesc,'') AS UserDesc
  3. ,'YOURDB'       AS Configuration
  4. ,ci.CreateDate AS CreateDate
  5. ,SUBSTRING(ci.CreationContext, CHARINDEX('ClientHost=',ci.CreationContext)+11 , CHARINDEX(';',ci.CreationContext,CHARINDEX('ClientHost=',ci.CreationContext)+11) - (CHARINDEX('ClientHost=',ci.CreationContext)+11)) AS ComputerName
  6. FROM        [YOURDB].dbo.connectioninformation ci
  7. JOIN        UserNames un
  8. ON          un.UserName     = ci.UserName
  9. WHERE ci.SessionType = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement