Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loop through databases on server, and update data

I have a server with multiple databases. I need to loop through these databases and change a value in one record, in one table, in each database. How can this be done?

like image 545
Curtis Avatar asked Jul 08 '10 17:07

Curtis


1 Answers

EXEC sp_MSForEachDB ' Use ?; UPDATE ?.dbo.MyTable SET MyValue=999  '
like image 90
rlb.usa Avatar answered Nov 15 '22 10:11

rlb.usa