-3

It is possible for SQL Server to auto delete certain rows from a table? I believe it's happened to me twice.

Already checked for stored procedures and DELETE FROM... queries in my code. I have my table inventory, it has no foreign keys; yesterday, before leaving the office, the information was there and today, only the stock information for a certain category was not there.

No one has access to this information. The log doesn't show anything related to this. I'm working with MS SQL Server 2016 in Windows server.

Thanks.

2 Answers 2

3

No. SQL Server wouldn't decide to simply delete (or truncate) a table of data. Something you, or another user has done is certainly the culprit. A few possibilities.

  • Someone ran a DELETE or TRUNCATE
  • You have a job that is restoring the database at night, which overwrote your data
  • You have a job set up to do a restore, refresh, or something similar to revert the DB to a state in time
  • Had you had foreign keys, you could have had CASCADE DELETE
  • Your INSERTS for the items that are missing were never committed, and was rolled back something
  • You are looking at the wrong database

How do you find out who / what?

2
  • I checked the log from 'sys.dm_exec_cached_plans' and there is nothing related to my problem, no jobs, no restores, it never had had foreign keys, and is not the wrong database, that's why I'm confused.
    – kuroyakedo
    Commented Sep 18, 2019 at 18:44
  • 1
    Cached plans are just that..., cached plans. Perhaps the plan wasn't cached in the first place, or something made that plan go out of cache. Commented Sep 19, 2019 at 7:26
0

Or perhaps your inserts are in a BEGIN TRANS and were never committed?

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