SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Determinating the space used in specific user table(s)


Determinating the space used in specific user table(s)

Author
Message
pavargasq
pavargasq
SSC Veteran
SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)

Group: General Forum Members
Points: 220 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
Glenn Dorling
Glenn Dorling
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4378 Visits: 932
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.
pavargasq
pavargasq
SSC Veteran
SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)SSC Veteran (220 reputation)

Group: General Forum Members
Points: 220 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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search