0

I am attempting to update most of my SQL Server tables and trying to figure out the best way to do this. I understand the trigger might be the best option but would that work with say, for example, 1000+ tables?

My aim/goal is to have data load into the tables with the current processes. At the moment those columns do not exist and do not have any data to tell you 1) last time it was updated with new data 2) who was the modified user.

I would like to add this information and just thought I ask what would be the best recommended way to go about this.

Thank You

cardiokhan
  • 29
  • 6
  • 1
    Triggers are probably the way to go. But just be aware that the last update user may or may not be available, depending on how users connect to the databases. If they connect through a web service for example the user will be a system account, unless you pass the actual user through from somewhere else. BTW if you only want datetime created (rather than modified) you can do that using a default on the column. – TomC Nov 18 '19 at 23:49
  • 1
    You may find [this question](https://stackoverflow.com/questions/31634918/how-do-i-add-a-last-modified-and-created-column-in-a-sql-server-table) useful to read. If you want to automate the creation of these triggers over a large number of tables, I'd suggest a cursor and some Dynamic SQL would be one way to achieve this, although possibly not the "best" or "recommended" way in other's opinions. – 3N1GM4 Nov 19 '19 at 13:44

0 Answers0