I am trying to get the table size for each table from a database using SQL Anywhere 11.
I just found out sp_spaceused
has been deprecated
Any help with this would be greatly appreciated! :)
SQL Anywhere 16 overview SQL Anywhere is a comprehensive package that provides technologies for data management and enterprise data exchange, enabling the rapid development of database-powered applications for server, desktop, mobile, and remote office environments.
SAP SQL Anywhere is a proprietary relational database management system (RDBMS) product from SAP. SQL Anywhere was known as Sybase SQL Anywhere prior to the acquisition of Sybase by SAP.
Possibly the system view SYSTAB can be a good-enough alternative. It can give you the number of rows in the table, and it can give you how many pages the table uses. (In the sample below, I'm multiplying the number of pages by the DB's page size to get a total byte size.)
SELECT
count, -- number of rows in the table
(table_page_count * DB_PROPERTY('PageSize')) tablesize
-- total size, in bytes
FROM SYSTAB
WHERE table_name = 'mytable'; -- or whatever limitations you want on
-- the scope of the query
Hope this helps.
You can use this script at Sql Server to find the largest table in Database and row count
SELECT sc.name +'.'+ ta.name TableName
,SUM(pa.rows) RowCnt
FROM sys.tables ta
INNER JOIN sys.partitions pa
ON pa.OBJECT_ID = ta.OBJECT_ID
INNER JOIN sys.schemas sc
ON ta.schema_id = sc.schema_id
WHERE ta.is_ms_shipped = 0 AND pa.index_id IN (1,0)
GROUP BY sc.name,ta.name
ORDER BY SUM(pa.rows) DESC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With