I have many different application databases with a [Log]
table. I have one central database with a similar log table, but with one extra column called TenantId
. There is also a Tenant
table with a TenantId
and a DatabaseName
column. These DatabaseName
contain the names of the application databases.
Now I want to loop all the application databases and copy the log entries to the central log table, with the TenantId
that belongs to the application database name.
Would it be possible to write one procedure in the central database instead of creating many procedures in the application databases? All databases are on the same SQL Server instance.