I need to confirm if a particular table ever existed in our SQL Server. Is there an existing script or method one can use to list all dropped databases in an SQL Server instance?
SQL Server – How to List All Dropped Databases
sql serversql-server-2008sql-server-2012
Related Question
- SQL Server – How to List All Tables from All User Databases
- Sql-server – Script to backup all databases
- SQL Server – Script to List Stored Procedures in All Databases
- TSQL Solution – Backup All Databases on All Server Instances
- Sql-server – List databases in Maintenance Plan
- SQL Server Compatibility Level – Based on Version
- SQL Server – How to List Extended Properties for All Databases
- SQL Server Users – How to Get List of Users on All Instance’s Databases
Best Answer
Well, I don't know about ever, since SQL Server doesn't keep that information around forever.
Also, it's unclear if you are asking about tables or databases. Since you mentioned both, here is a query against the default trace (based on this question) that will return either, but only going back as far as the default trace goes. It shows who dropped what, when, and from where.
The enum for
ObjectType
is documented here, but if you want to filter, you can useObjectType = 16964
for databases andObjectType = 8277
for tables.The default trace rolls off and purges the oldest rows/files as it adds new ones. If you need to go back further than that, you will need to resort to restoring older backups, if you still have them.