declare @query as nvarchar(max)
declare @dbname as nvarchar(max)
SET @query=''
SET @dbname ='TST'
SET @query =@query + @dbname + '..sp_msforeachtable '' select ''''?'''' as ''''Table'''', count(*) as ''''Rows'''' from ? '''
EXEC sp_executesql @query
Hope this helps if yes then accept the answer and vote it otherwise revert back with your queries
--Rahul D.