• 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.

    For example:

     SELECT  [DB_Name] = CASE WHEN database_ID = 32767 THEN 'ResourceDB' ELSE DB_NAME(database_id) END
            ,MB_Used   = COUNT(*)/128.0
       FROM sys.dm_os_buffer_descriptors
      GROUP BY database_id
      ORDER BY MB_Used DESC
    ;

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    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.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)