Technical Article

Get Record Counts for Each Table

,

This script creates a stored procedure that you can call to get the record count for every table in a particular database.  It uses the sp_MSforeachtable system stored procedure and a temp table.

create procedure DBA_GET_TBL_REC_CNT as
begin
set nocount on
create table #reccount (tbl_name varchar(100), rec_count int)
exec sp_MSforeachtable 'insert #reccount select ''?'',count(*) rec_count from ?'
select * from #reccount order by tbl_name
end
go

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating