‎10-18-2019 02:26 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename As AssetType,
Coalesce(tsysOS.Image, tsysAssetTypes.AssetTypeIcon10) As icon,
tsysIPLocations.IPLocation,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblAssetCustom.Serialnumber As scanner_serial,
tblAssetCustom.Custom7 As scanner_imei,
tblAssetCustom.PurchaseDate As scanner_purchase_date,
tblAssetCustom.Warrantydate As scanner_warranty_date,
tsysAssetRelationTypes.RelationTypeIcon10 As Icon3,
tsysAssetRelationTypes.ReverseName As RelationType,
ChildAsset.AssetName As hyperlink_name_ChildAsset,
tblAssetRelations.Comments As RelationComments,
tblAssetRelations.StartDate As RelationStartDate,
tblAssetRelations.EndDate As RelationEndDate,
ChildAsset.AssetTypeIcon10 As Icon2,
'/asset.aspx?AssetID=' + Cast(ChildAsset.AssetID As nvarchar(10)) As
hyperlink_ChildAsset,
'/Report/report.aspx?det=Web50getdomain&title=Computers in domain ' +
ChildAsset.Domain + '&@domain=' + ChildAsset.Domain As
hyperlink_ChildAssetDomain,
ChildAsset.AssetTypename As ChildAssetType,
Case
When tblAssetRelations.EndDate < GetDate() Then '#dddddd'
Else '#ffffff'
End As backgroundcolor,
tblADusers.Displayname
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblState On tblState.State = tblAssetCustom.State
Inner Join tsysIPLocations On tsysIPLocations.LocationID =
tblAssets.LocationID
Inner Join tblAssetRelations On
tblAssets.AssetID = tblAssetRelations.ParentAssetID
Inner Join tsysAssetRelationTypes On tblAssetRelations.Type =
tsysAssetRelationTypes.RelationTypeID
Inner Join (Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypeIcon10,
tblAssets.Domain,
tsysAssetTypes.AssetTypename,
tblAssets.IPAddress
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType =
tblAssets.Assettype
Where tblAssetCustom.State = 1) As ChildAsset On
tblAssetRelations.ChildAssetID = ChildAsset.AssetID
Left Outer Join tsysOS On tsysOS.OScode = tblAssets.OScode
Left Outer Join tblMacOSInfo On tblAssets.AssetID = tblMacOSInfo.AssetID
Left Outer Join tblLinuxSystem On tblAssets.AssetID = tblLinuxSystem.AssetID
Inner Join tblAssetUserRelations On
tblAssets.AssetID = tblAssetUserRelations.AssetID
Inner Join tblADusers On tblADusers.Username = tblAssetUserRelations.Username
Where tblAssetCustom.Manufacturer = 'Zebra' And tblAssetCustom.Model = 'TC57HO'
And tblState.Statename = 'Active'
Order By Case
When tblAssetRelations.EndDate Is Null Then 1
Else 0
End Desc,
RelationEndDate Desc,
RelationStartDate Desc,
tblAssets.AssetName
‎10-22-2019 08:35 PM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now