Get list of all databases that have a view named 'foo' in them
问题 I have a few servers that have a bunch of databases in them. Some of the databases have a view called vw_mydata. What I want to do is create a list of all databases containing a view named vw_mydata and then execute that view and store it's contents in a table that then contains al the data from all the vw_mydata. I know I can find all the databases containing that view using sp_msforeachdb 'select "?" AS dbName from [?].sys.views where name like ''vw_mydata''' But then I have as many