Update multiple tables in SQL Server 2005
I was required to update 40+ tables in our DB; Moran Benisty, our DBA master gave me a cool solution:
SELECT
‘update ‘ + name + ‘ set SomeColumn = ”SomeValue” where OtherColumn = ”SomeOtherValueToMatchBy”’
FROM
sys.objects
WHERE
name LIKE ‘LK_%’
Now all I had to do is copy the results and run them. Sweet !
BTW – use at your own risk. :)