Hi Again, I asked Chatgpt to analyze the query and the error message. Here goes the results:
❌ Identified Error
The issue is with the column mismatch between the UNION queries:
In your first SELECT inside the subquery, you return:
SELECT tblAssets.AssetID, tblAssets.Domain, tblAssets.Assettype, tblAssets.AssetName, tsysAssetTypes.AssetTypeIcon10 AS icon
But in the second SELECT (below the UNION), you have:
SELECT TOP 1000000 tblAssets_3.AssetID, tblAssets_3.Domain, '' AS IPAddress, 0 AS Assettype, tblAssets_3.AssetName, ...
🛑 The first SELECT has 5 columns, but the second SELECT has 6:
All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.
✅ How to Fix It
You need to align the column list in both parts of the UNION. Based on your outer query, you're expecting.
Is it possible to update the query or is it harcoded?
Thks!