Shawn Melton (5/5/2015)
Alan.B (5/5/2015)
I'm not trying to belittle Shawn's solution as he was just fixing your code.It is worth noting, however, that sp_MSForEachDB is undocumented and you should never use undocumented code in production environments. You could use a Dynamic SQL and sys.databases to accomplish the same thing.
I'm pretty sure the OP is aware of this as he stated: :hehe:
Please no replies about how sp_MSForeachdb is unreliable.
Thank you!
Yep. Duh (smacking own head)
-- Itzik Ben-Gan 2001