finding out which tables are the biggest

  • I’ve got a remote database that I need to download and restore to another server.

    The BAK file’s pretty big.(I’ve already shrunk the database and the files.The log file isn’t very big.

    I don’t remember that much data being on it.

    Data: 136192 KB

    Log: 1024 KB

    Is there any other way to reduce the size of the database, short of going in and deleting data?

    If not, I need to know which tables contain the most data…Can I find out the above via a query?

    Many thanks,

    yogi

  • Yogi,

    Check this out.

    http://sql-articles.com/scripts/table-space-details

  • run this

    declare @STR varchar(max)

    create table #tmpspace (name varchar(100), rows int, reserved varchar(200), data varchar(200), index_size varchar(200), unused varchar(200))

    select @STR = isnull(@str,'') + ' insert #tmpspace exec sp_spaceused [' + name + ']' from sys.tables

    exec (@str)

    update #tmpspace

    set data = replace(data,'kb','')

    select name [Table], rows [Rows], cast(data as int) [size(KB)] from #tmpspace

    order by cast(data as int) desc

  • hiya,

    Worked like treat.

    Thanks folks,

    yogi

  • That's only 136 Mega bytes... why the concern?

    --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)

  • hiya,

    I had to upload it from 1 server to another.

    When it was too big the web upload would timeout.

    cheers,

    yogi

  • Ah... got it. Didn't really register on me what you were doing. Thanks for the feedback.

    --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)

Viewing 7 posts - 1 through 6 (of 6 total)

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