"servicemanage" DB query - SLA
select I.Id_9A505725_E2F2_447F_271B_9B9F4F0D190C IRID, l.LTValue from [MT_System$WorkItem$Incident] I (nolock)
inner join [Relationship] r (nolock) on I.BaseManagedEntityId=r.SourceEntityId
inner join [MT_System$SLA$Instance$TimeInformation] s (nolock) on s.BaseManagedEntityId=r.TargetEntityId
inner join [EnumType] e (nolock) on e.EnumTypeId=s.Status_F632EA19_0367_CC81_BCB5_5E0387B1B5E3
inner join LocalizedText l (nolock) on l.ElementName=e.EnumTypeName
inner join [MT_System$SLA$Configuration] sc (nolock) on sc.DisplayName=s.DisplayName
where l.LanguageCode='ENU'
I want to add other columns like “Assigned User”, “Affected User”,“Support Group” Can you help me how can I do it ?
Best Answer
-
Olena_Prychyna Customer IT Monkey ✭just add:--System.WorkItemAssignedToUser-- left outer join Relationship r2 (nolock) ON I.BaseManagedEntityId = r2.SourceEntityId and r2.RelationshipTypeId = '15E577A3-6BF9-6713-4EAC-BA5A5B7C4722' and r2.IsDeleted = 0 inner join MT_System$Domain$User du2 (nolock) on du2.BaseManagedEntityId=r2.TargetEntityId --System.WorkItemAffectedUser-- left outer join Relationship r3 (nolock) ON I.BaseManagedEntityId = r3.SourceEntityId and r3.RelationshipTypeId = 'DFF9BE66-38B0-B6D6-6144-A412A3EBD4CE' and r3.IsDeleted = 0 inner join MT_System$Domain$User du3 (nolock) on du3.BaseManagedEntityId=r3.TargetEntityId --Support Group - TierQueue inner JOIN EnumType e2 (nolock) ON e2.EnumTypeId=I.TierQueue_1E9615C2_3386_2452_BA83_05B2169DF38C5
Answers
@Scott_Wright : it will be something like this - see attached
Instead of join EnumType you can do:
SELECT ... ,Display.DisplayName As Tier ....
JOIN DisplayStringView Display ON I.TierQueue_1E9615C2_3386_2452_BA83_05B2169DF38C = Display.MPElementId