{"id":6602,"date":"2023-07-14T07:03:00","date_gmt":"2023-07-14T05:03:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=6602"},"modified":"2023-09-18T14:05:00","modified_gmt":"2023-09-18T12:05:00","slug":"cannot-drop-the-database","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/","title":{"rendered":"Cannot drop the database because it is currently in use SQL Server Error"},"content":{"rendered":"\n<h4 class=\"wp-block-heading has-text-align-center\"><strong><em>How to fix the SQL Server error Cannot drop the database because it is currently in use?<\/em><\/strong><\/h4>\n\n\n\n<p>Also know as the 3702 error, the SQL Server error Cannot drop the database because it is currently in use is frequent in multi-user environments. It is possible to manage SQL databases with scripts or via the various windows of SQL Server Management Studio. For example, you can simply delete a database with a SQL DROP statement. However, if there are active connections on the database being deleted, then the database returns an error message, because a database with an active connection cannot be deleted.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#1-scripts-that-generates-the-drop-database-error\" >1. Scripts that generates the drop database error<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#2-execute-sp-who2-procedure-to-identify-ids-of-active-sessions\" >2. Execute sp_who2 procedure to identify IDs of active sessions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#3-close-sessions-with-the-sql-server-kill-command-and-spid\" >3. Close sessions with the SQL Server kill command and SPID<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#4-execute-again-the-drop-database-script-without-error\" >4. Execute again the drop database script without error<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-1-scripts-that-generates-the-drop-database-error\"><span class=\"ez-toc-section\" id=\"1-scripts-that-generates-the-drop-database-error\"><\/span>1. Scripts that generates the drop database error<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The exact error message text is the following:<\/p>\n\n\n\n<p><em><strong>Cannot drop database because it is currently in use. (Microsoft SQL Server, Error: 3702).<\/strong><\/em><\/p>\n\n\n\n<p class=\"has-text-align-left\"><strong><em>Note: Be careful to check the database backups before deleting it completely. Especially in important projects and production environments.<\/em><\/strong><\/p>\n\n\n\n<p>For example, this type of script generates the error: <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">USE [master];\nGO\n\nDROP DATABASE [DB1];\nGO\n<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Another way to create the database is to check if the DB exist on the server, before running the Drop Database command, like this for example: <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">USE [master];\nGO\n\nIF EXISTS (\n\tSELECT name \n\tFROM master.dbo.sysdatabases\n\tWHERE name = 'DB1'\n)\nDROP DATABASE [DB1];\nGO\n<\/pre>\n\n\n\n<p>To avoid this error, close all active connections to the database before the drop and terminate the current queries. Then close the tabs in SSMS or explicitly end the open connections on the database. Finally close the active tabs if only one user is currently connected. For the second step, run these two operations : <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2-execute-sp-who2-procedure-to-identify-ids-of-active-sessions\"><\/span>2. Execute sp_who2 procedure to identify IDs of active sessions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In the screenshot we identify the active sessions for the <strong>DB1 <\/strong>database. We see one user with <strong>SPID 51<\/strong>.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sp_who2\n<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/sql_server_command_sp_who2_check_spid.png\" alt=\"Cannot drop the database because it is currently in use run the sp_who2 command to to fix error 3702\" class=\"wp-image-6608\" style=\"width:849px;height:295px\" width=\"849\" height=\"295\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/sql_server_command_sp_who2_check_spid.png 849w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/sql_server_command_sp_who2_check_spid-300x104.png 300w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/04\/sql_server_command_sp_who2_check_spid-768x267.png 768w\" sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><figcaption class=\"wp-element-caption\"><em>Cannot drop the database because it is currently in use<\/em> &#8211; <em>run the sp_who2 command to to fix error 3702<\/em><\/figcaption><\/figure><\/div>\n\n\n<p><strong>Check out this other article about how to <a href=\"https:\/\/expert-only.com\/en\/dba\/create-sql-server-database-with-ssms\/\">create a database with default options with the SSMS<\/a> graphic user interface.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3-close-sessions-with-the-sql-server-kill-command-and-spid\"><\/span>3. Close sessions with the SQL Server kill command and SPID<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>It is the active SPID that prevent the drop from being successful. Indeed, <strong>the Microsoft RDBMS do not allow to drop a database with active sessions<\/strong>. Indeed, you need to terminate all the sessions with the SPIDs found. To do this, use the Server Process ID (SPID) found in the previous query to kill the session. Execute the query in SSMS.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kill 51\n<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"701\" height=\"283\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/12\/sql_server_command_kill_spid_active_session.png\" alt=\"Use the kill procedure to terminate the session with the SPID identified earlier\" class=\"wp-image-6614\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/12\/sql_server_command_kill_spid_active_session.png 701w, https:\/\/expert-only.com\/wp-content\/uploads\/2017\/12\/sql_server_command_kill_spid_active_session-300x121.png 300w\" sizes=\"auto, (max-width: 701px) 100vw, 701px\" \/><figcaption class=\"wp-element-caption\">Use the kill procedure to terminate the session with the SPID identified earlier<\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4-execute-again-the-drop-database-script-without-error\"><\/span>4. Execute again the drop database script without error<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Repeat the operation till no active connections are visible on the list. To go further, here is the official documentation of the <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/language-elements\/kill-transact-sql?view=sql-server-ver15\" target=\"_blank\" rel=\"noreferrer noopener\">T-SQL kill<\/a> command. The &#8220;unable to drop the database because it is currently in use&#8221; sql command error is a classical one. Indeed it&#8217;s an object that allows many connections from different users at the same time.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion on SQL Server error 3702<\/h3>\n\n\n\n<p>This MS SQL tutorial explains how to avoid the common SQL Server error message : <em>Cannot drop the database because it is currently in use<\/em>. It is a common error and the tip is very useful when creating and deleting multiple databases in development and testing environments for example.<\/p>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1649417243907\"><strong class=\"schema-faq-question\">How to completely drop a SQL Server database ?<\/strong> <p class=\"schema-faq-answer\">A database, unlike a table, cannot be erased or dumped. A database must be dropped, i.e., completely deleted to remove all its contents. Use the DROP DATABASE command to delete a SQL Server database.<\/p> <\/div> <\/div>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-wp-embed is-provider-sql-and-it-tutorials wp-block-embed-sql-and-it-tutorials\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"9NmsbeVYk0\"><a href=\"https:\/\/expert-only.com\/en\/dba\/clear-transaction-log\/\">Clear the SQL Server transaction log and fix the 9002 error<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Clear the SQL Server transaction log and fix the 9002 error&#8221; &#8212; SQL and IT Tutorials\" src=\"https:\/\/expert-only.com\/en\/dba\/clear-transaction-log\/embed\/#?secret=GtaO8xWdZx#?secret=9NmsbeVYk0\" data-secret=\"9NmsbeVYk0\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">SQL Server administration tutorials<\/h5>\n\n\n\n<p>To go further and learn more on MS databases management, check out this tutorials on the SQL Server DBA topic. <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/expert-only.com\/en\/dba\/clear-transaction-log\/\">Empty the SQL Server transaction log and fix error 9002<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/expert-only.com\/en\/dba\/install-second-instance\/\">How to install a second SQL Server instance on a server?<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/expert-only.com\/en\/dba\/query-to-display-sql-server-version\/\">How to display the SQL Server detailed version with a query?<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>How to fix the SQL Server error Cannot drop the database because it is currently in use? Also know as the 3702 error, the SQL Server error Cannot drop the database because it is currently in use is frequent <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/\" title=\"Cannot drop the database because it is currently in use SQL Server Error\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":5735,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[488],"tags":[],"class_list":{"0":"post-6602","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-dba"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.7 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Cannot drop database because currently in use - SQL Server Error<\/title>\n<meta name=\"description\" content=\"To fix the error 3702 cannot drop the database because it is currently in use with SQL Server, check and close all the active connections.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Cannot drop the database because it is currently in use SQL Server Error\" \/>\n<meta property=\"og:description\" content=\"To fix the error 3702 cannot drop the database because it is currently in use with SQL Server, check and close all the active connections.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL and IT Tutorials\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-14T05:03:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-18T12:05:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/06\/board-953155_1920-1024x576.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"576\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Expert-Only\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@expert_only\" \/>\n<meta name=\"twitter:site\" content=\"@expert_only\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Expert-Only\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"Cannot drop the database because it is currently in use SQL Server Error\",\"datePublished\":\"2023-07-14T05:03:00+00:00\",\"dateModified\":\"2023-09-18T12:05:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/\"},\"wordCount\":627,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/06\/board-953155_1920.png\",\"articleSection\":[\"SQL Server DBA\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/\",\"url\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/\",\"name\":\"Cannot drop database because currently in use - SQL Server Error\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/06\/board-953155_1920.png\",\"datePublished\":\"2023-07-14T05:03:00+00:00\",\"dateModified\":\"2023-09-18T12:05:00+00:00\",\"description\":\"To fix the error 3702 cannot drop the database because it is currently in use with SQL Server, check and close all the active connections.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#faq-question-1649417243907\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/06\/board-953155_1920.png\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/06\/board-953155_1920.png\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Cannot drop the database because it is currently in use SQL Server Error\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/expert-only.com\/en\/#website\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"name\":\"SQL and IT Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/expert-only.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/expert-only.com\/en\/#organization\",\"name\":\"Expert-Only\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"width\":381,\"height\":174,\"caption\":\"Expert-Only\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\",\"https:\/\/x.com\/expert_only\",\"https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\",\"name\":\"Expert-Only\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"caption\":\"Expert-Only\"}},{\"@type\":\"Question\",\"@id\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#faq-question-1649417243907\",\"position\":1,\"url\":\"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#faq-question-1649417243907\",\"name\":\"How to completely drop a SQL Server database ?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"A database, unlike a table, cannot be erased or dumped. A database must be dropped, i.e., completely deleted to remove all its contents. Use the DROP DATABASE command to delete a SQL Server database.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Cannot drop database because currently in use - SQL Server Error","description":"To fix the error 3702 cannot drop the database because it is currently in use with SQL Server, check and close all the active connections.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/","og_locale":"en_US","og_type":"article","og_title":"Cannot drop the database because it is currently in use SQL Server Error","og_description":"To fix the error 3702 cannot drop the database because it is currently in use with SQL Server, check and close all the active connections.","og_url":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2023-07-14T05:03:00+00:00","article_modified_time":"2023-09-18T12:05:00+00:00","og_image":[{"width":1024,"height":576,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/06\/board-953155_1920-1024x576.png","type":"image\/png"}],"author":"Expert-Only","twitter_card":"summary_large_image","twitter_creator":"@expert_only","twitter_site":"@expert_only","twitter_misc":{"Written by":"Expert-Only","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"Cannot drop the database because it is currently in use SQL Server Error","datePublished":"2023-07-14T05:03:00+00:00","dateModified":"2023-09-18T12:05:00+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/"},"wordCount":627,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/06\/board-953155_1920.png","articleSection":["SQL Server DBA"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/","url":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/","name":"Cannot drop database because currently in use - SQL Server Error","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/06\/board-953155_1920.png","datePublished":"2023-07-14T05:03:00+00:00","dateModified":"2023-09-18T12:05:00+00:00","description":"To fix the error 3702 cannot drop the database because it is currently in use with SQL Server, check and close all the active connections.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#faq-question-1649417243907"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/06\/board-953155_1920.png","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/06\/board-953155_1920.png","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"Cannot drop the database because it is currently in use SQL Server Error"}]},{"@type":"WebSite","@id":"https:\/\/expert-only.com\/en\/#website","url":"https:\/\/expert-only.com\/en\/","name":"SQL and IT Tutorials","description":"","publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/expert-only.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/expert-only.com\/en\/#organization","name":"Expert-Only","url":"https:\/\/expert-only.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","width":381,"height":174,"caption":"Expert-Only"},"image":{"@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ExpertOnlyCom\/","https:\/\/x.com\/expert_only","https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA"]},{"@type":"Person","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef","name":"Expert-Only","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","caption":"Expert-Only"}},{"@type":"Question","@id":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#faq-question-1649417243907","position":1,"url":"https:\/\/expert-only.com\/en\/dba\/cannot-drop-the-database\/#faq-question-1649417243907","name":"How to completely drop a SQL Server database ?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"A database, unlike a table, cannot be erased or dumped. A database must be dropped, i.e., completely deleted to remove all its contents. Use the DROP DATABASE command to delete a SQL Server database.","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/6602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/comments?post=6602"}],"version-history":[{"count":2,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/6602\/revisions"}],"predecessor-version":[{"id":27009,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/6602\/revisions\/27009"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/5735"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=6602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=6602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=6602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}