I respect anyone that will take the time to publish knowledge and, no... this isn't a slam. Just some helpful hints for your next post.
I think your script would have gotten better marks if you remembered the special but simple handling for the ResourceDB (which is what MS called it in one of their sample scripts) and if you had done your ORDER BY based on the column alias instead of repeating the formula. Also, you can easily convert page counts to megabytes simply by dividing by 128. Last but not least, you might want to do a spell check before you submit your post.
SELECT [DB_Name] = CASE WHEN database_ID = 32767 THEN 'ResourceDB' ELSE DB_NAME(database_id) END
,MB_Used = COUNT(*)/128.0
GROUP BY database_id
ORDER BY MB_Used DESC
is pronounced ree-bar and is a Modenism for R
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair
When you put the right degree of spin on it, the number 318
is also a glyph that describes the nature of a DBAs job. Helpful Links:
How to post code problemsHow to post performance problemsForum FAQs