Alok thanks for the response. We have two hundred dtabases. One way is to use
EXEC sp_MSForEachDB 'IF ''[?]'' NOT IN (''master'', ''model'', ''msdb'', ''tempdb'')
select top 10 ''[?]'',* from [?].dbo.individual1 o join [?].dbo.address1 c on o.ind_id =c.ind_id
'
But I am not sure how can I use the above with complex query that creates temp table for totals and does a select at the end.