Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Determinating the space used in specific user table(s) Expand / Collapse
Author
Message
Posted Thursday, February 26, 2009 7:05 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Saturday, December 8, 2012 8:24 PM
Points: 40, Visits: 135
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
Post #665445
Posted Thursday, February 26, 2009 8:31 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 5:24 PM
Points: 2,019, Visits: 866
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.
Post #665468
Posted Saturday, February 28, 2009 2:20 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Saturday, December 8, 2012 8:24 PM
Points: 40, Visits: 135
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
Post #666197
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse