One could use sp_msForEachDB builtin stored procedure. No cursor, no loop, and less chance to get into security issues.
Not quite right. If you look at the actual code sp_msForEachDB and the procedure that calls, its a cursor/loop on steroids. 😉
I am sorry for not being clear enough. My idea was that call of sp_msForEachDB eliminates a need to use cursor and loop explicitly. Less custom code - less headache 🙂
Thanks for the feedback 🙂
I prefer not to use sp_msForEachDB here for two reasons. Firstly, becase of it is not documented. And secondly, this proc is intended to search for a text in user's DB.