>I tried the following, but I think the the sp still looks at the tables from the current DB. I can insert the results from the original version into the temp table, then into another table. I was just trying to find a way to do it in one command.
>
>use MyDesignDB
>go
>create table tRowCount (tablename varchar(128), rowcnt int)
>exec sp_MSforeachtable
> 'insert into tRowCount select 'MyTestDB.' + ''?'', count(*) from 'MyTestDB.' + ?'
>select * from tRowCount
> order by rowcnt, tablename
>
Looks like you would not be able to do it. In my tries I was getting
Could not find server 'Database name' in sysservers. Execute sp_addlinkedserver to add the server to sysservers.
If it's not broken, fix it until it is.
My Blog