CREATE VIEW [dbo].[vw_SqlProcesses]
AS
SELECT     DB_NAME(ISNULL(tl.resource_database_id, 1)) AS DataBaseName, ec.session_id AS SessionId, ec.connect_time AS ConnectTime, 
                      CASE WHEN ec.last_read >= ec.last_write THEN ec.last_read WHEN ec.last_read < ec.last_write THEN ec.last_write END AS LastActivity, ec.connection_id AS ConnectionId, 
                      ec.client_net_address AS IPAddress
FROM         sys.dm_exec_connections AS ec LEFT OUTER JOIN
                      sys.dm_exec_requests AS er ON ec.connection_id = er.connection_id LEFT OUTER JOIN
                      sys.dm_tran_locks AS tl ON tl.request_session_id = ec.session_id
WHERE     (DB_NAME(ISNULL(tl.resource_database_id, 1)) NOT IN ('master', 'model', 'msdb', 'tempdb', 'Reports', 'Manager'))