Determinating the space used in specific user table(s)

  • Good evening

    Im new at SQL Sever, but i dont know if this question i may ask is simple or complicated.

    I know in order to get the space used in any database is sp_spaceused,

    but

    Iwas asked to get the spaceused in any table(s) for instance in table_name1, table_name2

    in my little knowledge i think its not easy because each table is determinated by filegroups and datafiles, and each datafile has more tables and other objects, isnt it?

    so its not acuurate this analysys,

    Just tell me, do i have to create any script or procedure to do that?

    i know i have to do this by myself but if you have any ideas to guide through this process, id appreciate your help

  • I'm guessing that you want to script this to check all tables.

    You can append a tablename to sp_spaceused to get the usage of a specific table. If you need to do multiple tables build and execute a script (eg. "select 'exec sp_spaceused ''' + name + '' from sysobjects where type = 'U'" then execute the resultant script).

    Note too that you may need to append the the 'updateusage' parameter if you haven't done that for a while.

  • Good afternnon, thanks for your idea, but its a little bit confusing for me this expression:

    i know the characret + is used to concatenate but the expression 'exec sp_spaceused '''

    itself what does mean?, when should i use simple quotes or doble quotes, and the construction of this instruction gets me a syntax error,

    when using double quotes:

    "select 'exec sp_spaceused ''' + name + '' from sysobjects where type = 'U' and name like 'paso_hechos%'"

    error: Could not find stored procedure 'select 'exec sp_spaceused ''' + name + '' from sysobjects where type = 'U' and name like 'paso_hechos%''.

    without double quotes:

    select 'exec sp_spaceused ''' + name + '' from sysobjects where type = 'U' and name like 'paso_hechos%'

    output:

    exec sp_spaceused 'PASO_HECHOS_TRAFICO_ABONADO

    exec sp_spaceused 'PASO_HECHOS_TRAFICO_LLAMADAS

    exec sp_spaceused 'PASO_HECHOS_TRAFICO_LLAMADAS_CDRS_TARJETA

    exec sp_spaceused 'PASO_HECHOS_TRAFICO_LLAMADAS_ENTRANTE_ELITE

    what is wrong with the above sentences?

    id appreciate again your help

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

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