Sp_MSforeachdb issues
I am trying to assign VIEW DEFINITION access to stored procedures in a development environment and execute the query below as "Result for Text", then copy the result and execute it as "Result for Grid":
select 'GRANT VIEW DEFINITION ON ' + quotename(specific_schema)
+ '.' + quotename(specific_name)
+ ' TO ' + 'TestAcct'
from INFORMATION_SCHEMA.routines
where routine_type = 'PROCEDURE'
The problem is that I have to do this against every database on multiple servers. I tried to run it with "sp_MSforeachdb" but when I customize the query I don't like my select statement. Any ideas on how to format the above query for all DBs so that I can copy the output and run it on the server instead of each individual DB?
+3
source to share