SELECT VI.VersionID, 
FF.Name, RF.RODBID VersionDBID
, .dbo.ve_GetShortPathFromContentID(CC.ContentID) Location
, CC.ContentID, RO.Value, RO.UsageID, 'R' + RO.ROID ROID
, RO.RODBID TextRODBID, RD.RONAME 
--, Count(*) HowMany
FROM CONTENTS CC
JOIN vefn_GetVersionItems('') VI ON VI.ContentID = CC.ContentID
JOIN DocVersions DV ON DV.VersionID = VI.VersionID
JOIN Folders FF ON FF.FolderID = DV.FolderID
JOIN Associations AA ON DV.VersionID = AA.VersionID
JOIN ROFSTS RF ON RF.ROFSTID = AA.ROFSTID
JOIN RODBS RD ON RD.RODBID = RF.RODBID
CROSS APPLY vefn_SplitROs(TEXT) RO
Where TEXT LIKE '%\v #Link:ReferencedObject:%'
--Group By 
--VI.VersionID, 
--FF.Name, RF.RODBID , RO.RODBID, RD.ROName