Using sp_spaceused to report on all tables for all databases including those on linked servers

  • I've been trying to come up with a good query/DMV to report on space used for the top X largest tables in a SQL server environment. I've come across a good solution that I really like http://www.sqlservercentral.com/Forums/Topic476475-8-1.aspx?Update=1 but it's lacking one feature I'd like to get implemented if possible. The solution in that link will pull back info for all tables in all DBs on a single server by making use of the sp_MSforeachdb, sp_MSforeachtable, and sp_spaceused stored procedures. It gets a little tricky since variables only stay valid for the duration of the procedures. What I'd like to do is get this to report on linked servers as well. I've been playing around with various ways to do it, and it seems feasible, but I'm still coming up short. I'm not sure if starting with the solution I linked to above is the best approach here, but I keep hitting dead ends with anything I try. Any help would be much appreciated.

    Thanks!

    -jared

  • Here is a script that works very well for table space. The linked server aspect though is something I have never considered adding to it. I just run it against the "linked" server direct.

    http://jasonbrimhall.info/2011/11/21/table-space-cs-part-deux/

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply