I have to implement auditing in a database with many (50+) tables. I am looking to add the user name and the time when the user altered the record as columns to all tables. However, some tables have the columns already, so I don't need to add the columns to all tables. Assuming the column names are
UserName_Table, how can I add
DateTime_Table column and
UserName_Table columns to all tables in the database if the columns don't exist?
I saw this loop for Postgres but I need help in SQL Server.