I\'d like to loop over a list of tables. For each table, I\'d like to run an update query.
Psuedo code:
ArrayOfTablesObjects = {[\'tablename1\',\'fieldn
You need to use dynamic SQL for this. The EXEC function will execute an ad-hoc sql statement passed in as a string.
DECLARE @UpdateSql AS varchar(2000)
foreach @tablename in ArrayOfTablesObjects
SET @UpdateSql = 'UPDATE ' + @tablename + ' SET ' + @fieldname ' + = ''xyz'' WHERE ' + @fieldname + ' = ''123'''
EXEC (@UpdateSql)
end foreach