DisCopy


Saturday, 16 July 2011

T-SQL script to see Rowcount of all the tables in an ASE Database.

select count(*) from each table in a database is colossal task and also degrades the performance of the Query.

This is a generic T-SQL script that would select all the tables and then does a row count of all tables in a Sybase ASE Database.

select o.name, rowcnt (i.doampg)
from sysobjects o, sysindexes i
where o.type = 'U'
and i.id = o.id
and i.indid < 2

An alternative is to use systabstats.rowcnt instead of sysindexes.rowcnt (doampg). However, if you are on 15.0 you have to use row_count () instead of rowcnt () which is depreciated now.

If you are using ASE-15.0 , Here is the script.
declare @dbid int
select @dbid = db_id()
select id, row_count(@dbid, id)
from sysobjects

No comments:

Post a Comment