2

I constantly run into this problem. I am working in a data warehouse and I cannot find out what is populating a table. Typically the table is being populated on a daily basis from either other table in the warehouse or from an Oracle database. I have tried the below query and can confirm the updates, but i cannot see what is doing it. I searched to the known SSIS package and stored procedure with similar names and SQL jobs but I can find nothing.

select object_name(object_id) as DatabaseName, last_user_update, *
from sys.dm_db_index_usage_stats
where database_id = DB_ID('Warehouse')
and object_id=object_id('PAYMENTS_DAILY')

I only have the most basic SQL Server tools available so no fancy search tools :(

3
  • Try looking for the table name in sys.sql_modules definition column.
    – Xedni
    Jul 29, 2015 at 17:37
  • 1
    May be you can add a trigger which will save user login and app name, and use that as starting point? Jul 29, 2015 at 17:38
  • 1
    A profiler trace or run sp_whoisactive periodically over a 24 hour period of time
    – billinkc
    Jul 29, 2015 at 17:43

2 Answers 2

2

There is no way to tell, after data has been inserted into a data, where the data came from without having some sort of logging.

SSIS has logging, you can use triggers on the tables, change data capture, audit columns, etc. are the many ways to do this.

1
  • Thanks, I suspected this was the case, but I really didn't want it to be.
    – Holmes IV
    Jul 29, 2015 at 19:09
0

Frequently, if you know when the row was added, that can help you figure out what process is adding it. Add a new "InsertedDatetime" column to your warehouse table and give it a default value of getdate(). If you know that the rows always come in at 11:15 AM, you can use that to narrow your search.

That will probably be enough information, but if that doesn't help you track down the process, then you can add additional columns that contain everything from a source IP address to a calling object name.

As a last resort, you could rename your table and create a view named the same and then use an Instead Of Insert trigger on it that just holds open the connection so you can examine the currently executing processes to figure out where it's coming from.

I bet you can figure it out from the time alone though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.