Playing around with EPM ( i was trying retrieve the results of a nightly policy into a report. The problem was that the column for the database name is in the below format.


and i only wanted to write out ReportServer.

To do it (im sure its not the best way..) i ended up reversing the string then finding the last “\” then deleting everything to one side of it and again reversing it back.. all very long winded but it worked 🙂

SELECT EvaluatedServer ,
REVERSE(LEFT(REVERSE(EvaluatedObject), CHARINDEX('\',REVERSE(EvaluatedObject))-1)) AS 'database',
FROM policy.PolicyHistoryDetail
WHERE CategoryName = 'Backup_Details'
ORDER BY PolicyResult

Results looked like