Firstly fork
data.stackexchange.com/stackoverflow/query/69701/… to prepare to receive a pasted set of Select ... Union All ... Select. Assuming the database order returned is the same for you, copy the text from the first 'Select ' after the 'Data.StackExchange', 'master', 'model', and 'msdb' to the end, excepting the final Union All and the Select 'tempdb'.