How to find the disk size of a table in Microsoft SQL Server

1.Connect to the SQL server instance. Depending on what I'm doing, I usually use SQL Management Studio, or my own custom script / application.

2.Execute "sp_spaceused". As you can imagine there are a few commands that will allow you to figure out your table size. I prefer "sp_spaceused".

usage: "sp_spaceused 'Name of your table'"
example: "sp_spaceused 'user_accounts'"

Yes, the table name is treated like a varchar / string for this command. Something else to keep in mind is that this particular procedure looks at the [sysindexes] system table. There are instances where this table can become a little out of sync; like right after an index is dropped. To compensate for this, there is an optional parameter that you can add to force the recalculation before execution. Just simply add a "true" to the end.

example: "sp_spaceused 'user_accounts', true"

For reference, the true simply forces the system to recalculate by executing "dbcc updateusage (0)" for all the tables, or "dbcc updateusage ('Name of your table')" for a specific table.

3. Analyze the results. The data returned includes the "name", "rows", "reserved", "data", "index_size", and "unused".

- "name", the name of the table.
- "rows", the number of records in the table.
- "reserved", the amount of space currently allocated for the table.
- "data", the current space used by the table's data.
- "index_size", the current size of the table's indexes.
- "unused", the amount of unused space reserved for the table.

Hiç yorum yok:

2018 SGK İşten Çıkış Kodları (696 sayılı KHK kapsamında eklenenler dahil)

2018 SGK İşten Çıkış Kodları 1- Deneme süreli iş sözleşmesinin işverence feshi 2- Deneme süreli iş sözleşmesinin işçi tarafından feshi ...