I have a report that pulls the first and last name of the assigned owner. For some reason, when there is no owner assigned, it does not pull information for that asset. I need it to pull all assets and include the owner information when it exists. Can someone take a look below and see what I may be doing wrong? Any help is appreciated.
declare @RAAssetUser uniqueidentifier
set @RAAssetUser = 'ed35a8d1-bf60-4771-9dde-092c146c485a'
--remove rowcount contraints as this will limit result sets - default for reporting is 50000
SET ROWCOUNT 0
select distinct
va.[_ResourceGuid] [_ResourceGuid],
dbo.fnLocalizeStringByGuid('
item.name',va._ResourceTypeGuid, '%_culture%') [Asset Type],
vri.[Name] [Name],
htLoc.Name [Location],
irn.[Number][Room Number],
iai.[SCC Tag #][SCC Tag#],
va.[Serial Number] [Serial Number],
va.[Manufacturer] [Manufacturer],
va.[System Number][System Number],
va.[Model] [Model],
u.[Given Name] [First Name], u.Surname [Last Name],
htCC.Name [Cost Center]
from
vAsset va
join %SecurityFilterParameter% vri
on vri._ResourceGuid = va._ResourceGuid
join ResourceAssociation ra ON va._ResourceGuid = ra.ParentResourceGuid
join vUser u ON u.guid = ra.ChildResourceGuid
join Inv_Room_Number irn on (irn._ResourceGuid = va._ResourceGuid)
join Inv_Asset_Information iai on (iai._ResourceGuid = va._ResourceGuid)
join ResourceTypeHierarchy rth
on (rth.ResourceTypeGuid = va._ResourceTypeGuid)
left join ResourceAssociation raAL
on (raAL.ResourceAssociationTypeGuid = '05DE450F-39EA-4AAE-8C5F-77817889C27C') -- Asset:Location ResourceAssociationType
and (raAL.ParentResourceGuid = va._ResourceGuid)
left join fnAssetHierarchyTreeExcludeChildren
(
'834BC951-D70F-48F4-9E8E-D7E32C68788D', -- Location ResourceType
'',
default,
'%Location%',
default
) htLoc
on (htLoc.Guid = raAL.ChildResourceGuid)
and ((htLoc.Guid <> 0x0) or ('%Location%' = cast(0x0 as uniqueidentifier)))
left join ResourceAssociation raAC
on (raAC.ResourceAssociationTypeGuid = '9BC22D17-C0CF-45D5-9A8F-D62BBAFD955D') -- Asset:CostCenter ResourceAssociationType
and (raAC.ParentResourceGuid = va._ResourceGuid)
left join fnAssetHierarchyTreeExcludeChildren
(
'03E525D8-43B1-4AE3-8592-9A9E5AE9C8C0', -- CostCenter ResourceType
'',
default,
'%CostCenter%',
default
) htCC
on (htCC.Guid = raAC.ChildResourceGuid)
and ((htCC.Guid <> 0x0) or ('%CostCenter%' = cast(0x0 as uniqueidentifier)))
where (1=1)
--// filter by Type //--
and ((rth.BaseResourceTypeGuid = '%Type%') or ('%Type%' = cast(0x0 as uniqueidentifier)))
--// filter by Location and IncludeAllLoc //--
and ((htLoc.Guid = '%Location%') or ('%Location%' = cast(0x0 as uniqueidentifier)) or (%IncludeAllLoc% = 1))
and ((htLoc.Guid <> 0x0) or ('%Location%' = cast(0x0 as uniqueidentifier)))
--// filter by CostCenter and IncludeAllCC //--
and ((htCC.Guid = '%CostCenter%') or ('%CostCenter%' = cast(0x0 as uniqueidentifier)) or (%IncludeAllCC% = 1))
and ((htCC.Guid <> 0x0) or ('%CostCenter%' = cast(0x0 as uniqueidentifier))
and (ra.ResourceAssociationTypeGuid = 'ED35A8D1-BF60-4771-9DDE-092C146C485A' ))
order by [Location],[Room Number]