{"id":18093,"date":"2020-08-21T09:56:23","date_gmt":"2020-08-21T09:56:23","guid":{"rendered":"https:\/\/ittutorial.org\/?p=18093"},"modified":"2020-08-21T10:06:58","modified_gmt":"2020-08-21T10:06:58","slug":"ways-to-track-deleted-database-in-sql-server","status":"publish","type":"post","link":"https:\/\/ittutorial.org\/ways-to-track-deleted-database-in-sql-server\/","title":{"rendered":"Ways to Track Deleted Database in SQL Server"},"content":{"rendered":"<p>SQL Server&#8217;s Schema Changes History we can recognize the name of databases that were dropped from the SQL Server. In a big SQL Server environment, interfacing with each Schema Changes History of each SQL Server case is an extremely troublesome task. In this blog, we will take a glance at the steps which you can trace to a rapidly auto-track deleted database in SQL Server.<\/p>\n<blockquote><p><strong>Important Solution:<\/strong> Are you facing problems in recovering deleted database components from SQL Server if yes then try <a href=\"https:\/\/www.sqlrepairtool.org\/\">SQL Repair Tool<\/a> Software to export deleted database object live to SQL Server.<\/p><\/blockquote>\n<p><a href=\"https:\/\/systoolskart.com\/download\/SYS1S2Q7L\/116\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-17655 aligncenter\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2020\/08\/download-2-300x100.jpg\" alt=\"\" width=\"300\" height=\"100\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2020\/08\/download-2-300x100.jpg 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2020\/08\/download-2-768x256.jpg 768w, https:\/\/ittutorial.org\/wp-content\/uploads\/2020\/08\/download-2.jpg 820w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>There are two unique techniques by which one can without much effort track who deleted the database in SQL Server. The principal technique is using the built-in Schema Changes History Report. The subsequent technique is to load the SQL Server Default Trace into a table to see who deleted the database.<\/p>\n<h2>Methods to <strong>Track Deleted Database in SQL Server<\/strong><\/h2>\n<p><strong>1. Track Database Using SQL Server Schema Changes History Report <\/strong><\/p>\n<ol>\n<li>Open SQL Server Management Studio and connect with the SQL Server Instance.<\/li>\n<li>Right-click SQL Server Instance and Select Reports &#8211; &gt; Standard Reports &#8211; &gt; Schema Changes History.<\/li>\n<li>Then, <strong>Scheme Changes History report <\/strong>will open, which will have the insights concerning who deleted the SQL Server Database along with the time when the database was deleted.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p><strong>2.Track Database Using Default Trace Files <\/strong><\/p>\n<p>The SQL Server Default Trace file gives exceptionally helpful data to a DBA to comprehend what&#8217;s going on the SQL Server Instance.<\/p>\n<p>Execute the below query to trace the default path of trace file in SQL Server.<\/p>\n<p><strong><em>SELECT<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0path AS [Default Trace File]<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ,max_size AS [Max File Size of Trace File]<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ,max_files AS [Max No of Trace Files]<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ,start_time AS [Start Time]<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ,last_event_time AS [Last Event Time]<\/em><\/strong><\/p>\n<p><strong><em>FROM sys.traces WHERE is_default = 1<\/em><\/strong><\/p>\n<p><strong><em>GO<\/em><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Step by Step Instructions to Load SQL Server Trace File in SQL Server Table <\/strong><\/p>\n<p><strong>Note:<\/strong> Try <a href=\"https:\/\/www.sqlrecoverytool.com\/sql-log-analyzer.html\">SQL Log Analyser Software<\/a> to Recover Database from Corrupted LDF Files.<\/p>\n<p>Execute the beneath script to load the default trace file content in a transitory table to read the significant data as for who deleted the client database in SQL Server. If you don&#8217;t find the significant data in the most recent trace file, at that point it is prescribed to load the data from all the accessible trace files on the server to explore the data.<\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>USE tempdb<\/em><\/strong><\/p>\n<p><strong><em>GO<\/em><\/strong><\/p>\n<p><strong><em>IF OBJECT_ID(&#8216;dbo.TraceTable&#8217;, &#8216;U&#8217;) IS NOT NULL<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DROP TABLE dbo.TraceTable;<\/em><\/strong><\/p>\n<p><strong><em>SELECT * INTO TraceTable<\/em><\/strong><\/p>\n<p><strong><em>FROM ::fn_trace_gettable<\/em><\/strong><\/p>\n<p><strong><em>(&#8216;G:\\Program Files\\Microsoft SQL Server\\MSSQL10_50.SQL2008R2\\MSSQL\\Log\\log_12.trc&#8217;, default)<\/em><\/strong><\/p>\n<p><strong><em>GO<\/em><\/strong><\/p>\n<p><strong><em>SELECT<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0DatabaseID<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ,DatabaseName<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ,LoginName<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ,HostName<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ,ApplicationName<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ,StartTime<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ,CASE<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 WHEN EventClass = 46 THEN &#8216;Database Created&#8217;<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 WHEN EventClass = 47 THEN &#8216;Database Dropped&#8217;<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ELSE &#8216;NONE&#8217;<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 END AS EventType<\/em><\/strong><\/p>\n<p><strong><em>FROM tempdb.dbo.TraceTable<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 WHERE DatabaseName = &#8216;MyTechMantra&#8217;<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 AND (EventClass = 46 \/* Event Class 46 refers to Object:Created *\/<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OR EventClass = 47) \/* Event Class 47 refers to Object:Deleted *\/<\/em><\/strong><\/p>\n<p><strong><em>GO<\/em><\/strong><\/p>\n<p><strong>\u00a0\u00a0<\/strong><\/p>\n<h3><strong>Wrap Up<\/strong><\/h3>\n<p>In this blog, we have perceived how effectively one can track a deleted database in SQL Server with the assistance of an inbuilt SQL Server Schema Changes History Report or by using default trace files. Moreover, if your database files are corrupted or highly damaged then, in order to recover the database files, we recommend using a third-party tool such as <strong>SQL Recovery Sofware.\u00a0<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL Server&#8217;s Schema Changes History we can recognize the name of databases that were dropped from the SQL Server. In a big SQL Server environment, interfacing with each Schema Changes History of each SQL Server case is an extremely troublesome task. In this blog, we will take a glance at the steps which you can &hellip;<\/p>\n","protected":false},"author":10094,"featured_media":16838,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2227],"tags":[12432],"class_list":["post-18093","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-sql-server-2","tag-ways-to-track-deleted-database-in-sql-server"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/ittutorial.org\/wp-content\/uploads\/2020\/07\/backups-in-sql-server.png","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/18093","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/users\/10094"}],"replies":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/comments?post=18093"}],"version-history":[{"count":1,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/18093\/revisions"}],"predecessor-version":[{"id":18094,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/18093\/revisions\/18094"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media\/16838"}],"wp:attachment":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media?parent=18093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/categories?post=18093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/tags?post=18093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}