IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[pTableRowCountStart]') 
AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [dbo].[pTableRowCountStart]
GOcreate procedure PTableRowCountStart
with encryption
as
begin
if exists(select name from sys.objects where type='U' and name='TableName')
 drop table TableName
if exists(select name from sys.objects where type='U' and name='TableRowCountStart')
 drop table TableRowCountStart
 
create table TableName(name varchar(2000))
create table TableRowCountStart(TableName varchar(100), ncount int)
insert into TableName select name from sys.objects  where type='U' 
declare  @name varchar(200)='',@sSQL varchar(500)=''
declare  Tcursor Cursor
for select * from TableName
open Tcursor
fetch next from Tcursor into @name
while(@@FETCH_STATUS=0)
begin
if (@name='TableName' or @name='TableRowCountStart'  or @name='TableRowCountend')
begin
 fetch next from Tcursor into @name
end
else
begin
select @sSQL='insert  into tableRowCountStart '+'select Tablename='''+@name+''', count(*) as ''nCount'' from '+CONVERT(varchar(500),@name)
exec(@sSQL)
select @sSQL=''
fetch next from Tcursor into @name
end
end
close Tcursor
DEALLOCATE Tcursor
end