It seems this post was one of the casualties of my hosting provider dropping out on me and infrequent backups.  I was tasked to give a portion of a clients database to another contractor so they could handle a specific subset of customers.  For various reasons they wanted just a database backup and we of course just wanted to give them a csv.

In the end we decided to mirror the database locally, drop all the unrelated tables and make sure all the tables remaining only included relevant records.  Before I started dropping tables I was going to make sure I had zeroed out all the record counts and remembered this snippet of code that would show me record counts for all the tables in my catalog.

Easy right?  I put this code on my blog so a quick search should pull it up, nope, one of the missing entries.

Here it is again: 

create table #rowcount (tablename varchar(128), rowcnt int)
exec sp_MSforeachtable 
 @command1 
'insert into #rowcount select ''?'', 
              count(*) from ?'
,
 @whereand 
'and name like ''p%'''
select top from #rowcount
    order by 
tablename
drop table #rowcount
I discovered this bit of code here.