In the situation where you must support more than one AX environment with the same SQL Server, maintenance can become tricky unless you know who is online.  The following SQL Script will list all of the users who are online.

EXECUTE master.sys.sp_MSforeachdb ‘USE [?]; IF OBJECT_ID(”?.dbo.[SysClientSessions]”, ”U”) IS NOT NULL  SELECT ”?” AS [Db], UserId, LoginDateTime, ClientComputer FROM SysClientSessions WHERE status=1 AND clienttype=0’