For more complicated reports, I use SSMS query analyzer on the server, make my queries, and from there, insert it in to the database - as the report writer/GUI does not work with some SQL syntax/functions.
Here's what they told me for my support ticket
• Make a backup of your database
• Run the first query below and insert a Reportquery name and Reporttitle:
Insert Into tsysreports ( [Reportquery],[Reporttitle]) Values('MyReportQueryName', 'MyReportTitle')
• Once the first query has been run we can run a second query to insert your report query to the database. Replace the green highlighted query with your query do note that you may have to replace any single quotes in the report query with double quotes to avoid any issues to insert it. Finally replace the yellow highlighted code with the Reportquery name that you gave in previously:
Insert Into tsysDBobjects(Query, DBobjName) Values('Select distinct assetid,backedupto = STUFF((Select distinct tblassets.assetid,'', '' + tblAssets4.assetname as backedupto
from tblAssets
left Join (Select distinct tsysAssetRElationTypes.Name, tsysAssetRelationTypes.RelationTypeID,tblassets.assetname, tblAssetRelations.ParentAssetID,tblAssetRelations.ChildAssetID from tblAssets
Left Join tblAssetRelations On tblAssetRelations.ChildAssetID = tblAssets.AssetID
Left Join tsysAssetRelationTypes On tsysAssetRelationTypes.RelationTypeID = tblAssetRelations.Type
Where tsysAssetRelationTypes.Name = ''backed up to'') As RR
On RR.ChildAssetId = tblassets.assetid
Left Join tblAssetRelations On tblAssetRelations.ChildAssetID = tblAssets.AssetID
Left Join tsysAssetRelationTypes On tsysAssetRelationTypes.RelationTypeID = tblAssetRelations.Type
Left Join tblAssets tblAssets4 On tblAssets4.AssetID = rr.ParentAssetID
Where tsysAssetRelationTypes.Name = ''backed up to'' and tblassets.assetid=ttt.assetid
group by '', '' + tblassets4.assetname, tblassets.assetid
FOR XML PATH(''''), TYPE).value(''.[1]'', ''nvarchar(max)''), 1, 4, '''')
from
tblassets as TTT
Group by assetid', 'MyReportQueryName')
• The report can now be found in the Lansweeper Reports section and be run.