Search entire database
I'm wondering if you can use the undocumented stored proc sp_MSforeachtable rather than use cursors?  Here's a little bit of code that brings back the number of rows in each table. Can you modify it to do what you need to do?

use pubs2014
go
create table #rowcount (tablename varchar(128), rowcnt int)
exec sp_MSforeachtable
'insert into #rowcount select ''?'', count(*) from ?'
select top 5 * from #rowcount
order by tablename
drop table #rowcount


And yes, I've brought both the pubs and the Northwind databases forward into SQL 2014 AND 2016...I'm nostalgic, what can I say?