Recover SQL/SWQL widgets from database (sql)

Hi All

There was an instance where client needed to create a new Orion database; however the SQL/SWQL from the old database were forgotten to be backed up.  

This script will display the widgets with the SQL/SWQL code which can be copied to the new instance of Orion.  Nice and simple and effective.


use SOlarWindsOrion

SELECT v.ViewGroupName, v.ViewTitle,r.ResourceTitle, rp.PropertyName, rp.PropertyValue

FROM Views v

join Resources r on r.ViewID = v.ViewID

join ResourceProperties rp on rp.ResourceID=r.ResourceID

where rp.PropertyName in('sql','swql') and ViewGroupName like '%loop%'

Thank you,