If you need to create a batch select or update or delete statement list, use the following sql, which queries the sys.tables in ms sql server.

SELECT 'DELETE from ' + t.name + ' WHERE account not like ''TEST%''' AS table_name
FROM sys.tables AS t
WHERE t.name like 's_account%'
order by 1
SELECT 'SELECT * from ' + t.name + ' WHERE account not like ''TEST%''' AS table_name
FROM sys.tables AS t
WHERE t.name like 'dim_account%'
AND  t.name not like '%old'
order by 1

 

Share This Via: