Search code examples
sql-serversp-msforeachdb

I want to update a table in each db on server


I have a config table with same fields "SMTP_Server". I want to update the fields with new value in each database on the server.

sp_foreachdb updates last table (in last database). Why?

please help


Solution

  • This sp doesn't seem to be "officially" supported and sometimes has problems...

    See: Making a more reliable and flexible sp_msforeachdb at http://www.mssqltips.com/tip.asp?tip=2201&home

    ...I have discovered instances where, under heavy load and/or with a large number of databases, the procedure can actually skip multiple catalogs with no error or warning message. Since this situation is not easily reproducible, and since Microsoft typically has no interest in fixing unsupported objects, this may be happening in your environment right now. ...