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 !