Link to home
Start Free TrialLog in
Avatar of marcgimbrere
marcgimbrere

asked on

Why is data is disappearing from my SQL Server 2005 table?

I've been writing asp code for SQL Server web applications for years and have come up with a problem that has me stumped.

In short, data in one of my tables is periodically and arbitrarily being deleted.  Not ALL the data, just SOME of it.  And each time it happens, it is different data.  It's happening once or twice a week at inconsistent intervals as far as I can tell.

The table is quite narrow (only two fields) but also quite critical as it ties two other tables together and is really important for my client's cash flow.

I have checked the code inside and out and there are NO locations within the code from which to delete the data except one administrative module; using this module it would take DAYS (as well as admin clearance) to delete the amount of data that is regularly disappearing from this table, and those in the company with administrative clearance insist that they are not doing the deleting (there is no reason that they should!)

And yet the data continues to be deleted, and I continue having to restore an older versions of the table.

This system has over 80 tables and it's only happening to this one!  It's truly bizarre!

HOW THE HECK COULD THIS BE HAPPENING?  ALL IDEAS ARE WELCOME, THIS ONE HAS REALLY GOTTEN ME!

Thanks

Marc
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

you methods (can be combined):
? create a trigger on the table, to log information when/who is doing the deletes.
? run a sql profiler to trace the deletes on that table

Avatar of marcgimbrere
marcgimbrere

ASKER

how do i set up a trigger on the table to log information when/who is doing the delete?
ASKER CERTIFIED SOLUTION
Avatar of vasureddym
vasureddym

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks I am trying this approach top debug but of course it doesn't tell me what the core problem is...I'll get back to you when the mass deletion occurs again and we can look into the reasons why...meanwhile I'm leaving this open if thats OK with you.

Cheers

Marc
ok, so the question of the day is, can you set up a trigger to check to see if a single FIELD has changed?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, using these techniques I found
Using these techniques I found the error, thanks
OK, this is weird, I found the solution to the problem and deleted the trigger from the triggers section of the database, but now when I delete data from the table, the trigger still runs and throws an error because it cannot find the table to put the trigger information into:

Microsoft OLE DB Provider for SQL Server error '80040e37'

Invalid object name 'LOG_AUDIT_TBL_SPEAKER_KEYWORDS'.

/speaker_keywords.asp, line 19

I can't work out what is going on, there is nothing in the trigger section in SQL 2005 Management Studio - any ideas?
>I can't work out what is going on, there is nothing in the trigger section in SQL 2005 Management Studio - any ideas?

the triggers are listed below the table they are attached to.
what you see under "Server objects => Triggers" are the triggers for server-wide ddl triggers.
thanks, doh, I still have more to learn, that worked great
marc