updating the same field in multiple databases at the same time

  • I need to update the same filed in about 40 databases to Yes (1)  at the some time based on a query. Any thoughts?????

  • Create linked servers to all servers that count  and depending on the results of your query , update the fields on the server in question using the linked servers

     

    Mike

     

  • They are on the same server, just diffrent databases. I can not use a union because I am updating

     

  • Look into sp_msforeachdb. It would work something like this:

    sp_msforeachdb 'if ''?'' not in (''master'', ''model'', ''msdb'', ''tempdb'')

    update ?.dbo.table1 set column = ''yes'' '

  • I did not know about that procedure. That is awesome. Thanks

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply