SELECT TOP 1 * FROM
(
select max(updatedtimestamp) from db1.dbo.policyrepresentationcache with(nolock)
UNION
select max(updatedtimestamp) from db2.dbo.policyrepresentationcache with(nolock)
)
ORDER BY updatedtimestamp
I’m running into syntax errors here and im not sure how to set it up.
You’re just missing an alias for the table produced by the union. I’ve aliased it as a below.