Question : Print SQL exec results

I'm running a loop that creates a sql statement and then executes it. This loop goes through each DB on my server. What I want to do is, instead of executing 50 or so sql statements I'd like it to print each sql statments results...

Something like:

Print exec (@Command) ????

Is this possible?
Code Snippet:
1:
2:
3:
4:
5:
6:
set @Command = 'USE [' + @d + ']
			
            SELECT  db_name(),  count(*) 
            FROM    [' + @d + '].dbo.table where [Column] = ''Value'';'
   
exec (@command)

Answer : Print SQL exec results

Never mind...just figured it out...I set it to return results to text instead of return results to grid. This gets me what I need. Thanks!!!!
Random Solutions  
 
programming4us programming4us