I am not sure how to use dynamic SQL.
But I found a reference to using CURSOR that does not take an argument as input. So please tell me if there is a different way to do what I need to do.
Basically I want to use the output of dbo.sysdatabases to run a select statement in each database calling a specific table.
I cheated by creating a stored procedure in each DB and then using an INSERT to a temp table for the output of each SP and then adding that as the report. But I have to add the SP to each DB and there are hundreds of DB's. It would be much easier if I could just use each DB Name in sysdatabases as the argument.
Thanks for your help in advance.