/****** Script for SelectTopNRows command from SSMS  ******/
SELECT j.[JobId]
      ,j.[JobState]
      ,j.[ExecutionTimeMs]/1000/60/60 AS ExecutionTimeHours
      ,DATALENGTH(jd.data)/1024.0/1024.0 AS MB
      ,he.Name AS Experiment
      ,he.DateCreated   
      ,u.UserName
      ,j.[LastHeartbeat]
      ,j.[Priority]
      ,j.[CoresNeeded]
      ,j.[MemoryNeeded]
      ,j.[IsPrivileged]
      ,j.[Command]
      ,j.[IsParentJob]   
      ,j.[FinishWhenChildJobsFinished]
      ,j.[ParentJobId]
      , he.HiveExperimentId
  FROM 
	[HeuristicLab.Hive-3.4].[dbo].[Job] j
	,[HeuristicLab.Hive-3.4].[dbo].[HiveExperiment] he
	,[HeuristicLab.Authentication].dbo.aspnet_Users u
	,[HeuristicLab.Hive-3.4].dbo.JobData jd
  WHERE
	j.HiveExperimentId = he.HiveExperimentId
	AND j.JobId = jd.JobId
	AND he.OwnerUserId = u.UserId
	--AND he.DateCreated > '06-03-2011 10:30'
	
ORDER BY j.JobState, he.DateCreated DESC