Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Sybase > Record Count

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-01-08, 08:11
karthi_syb karthi_syb is offline
Registered User
 
Join Date: Jun 2008
Location: India
Posts: 58
Record Count

Hi All,

I have written the below query to know the record count of all tables for a particular DB.

select N = IDENTITY(5), name into #tables
from sysobjects
where type = 'U'

Create table #Result
(
TableName varchar(50),
RecordCount int
)

Declare @Sql varchar(2000),@TableName varchar(50)
Declare @Min int,@Max int
set @Min = 1
select @Max = max(N) from #tables


while @Min <= @Max
Begin

Select @TableName = name from #tables
where N = @Min

Select @Sql = 'Insert into #Result Select ' + ''''+@TableName+'''' + ',count(*) from ' + @TableName
print @Sql
exec (@Sql)
select @Min = @Min + 1
End

is there any other way to do the same job ?

Inputs are welcome !
Reply With Quote
  #2 (permalink)  
Old 07-02-08, 06:07
karthi_syb karthi_syb is offline
Registered User
 
Join Date: Jun 2008
Location: India
Posts: 58
Any inputs ?
Reply With Quote
  #3 (permalink)  
Old 07-02-08, 06:13
mike_bike_kite mike_bike_kite is offline
Registered User
 
Join Date: Jun 2007
Location: London
Posts: 944
Try the following - it's not 100% accurate but it's close :
Code:
select tab = o.name, cnt = sum(rowcnt(i.doampg)) from sysobjects o, sysindexes i where o.id=i.id and o.type='U' and not ( o.sysstat2 & 1024 = 1024 ) group by o.name order by o.name

MBK
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On