{"id":9462,"date":"2022-05-13T06:06:00","date_gmt":"2022-05-13T04:06:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=9462"},"modified":"2023-03-10T10:12:58","modified_gmt":"2023-03-10T09:12:58","slug":"drop-a-table-with-a-sql-server-script","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/","title":{"rendered":"How to drop a SQL Server table with a script?"},"content":{"rendered":"\n<h4 class=\"has-text-align-center wp-block-heading\" id=\"h-how-to-drop-one-or-multiple-sql-server-tables-using-a-t-sql-script-and-how-to-check-the-existence-of-the-table\"><strong><em>How to drop one or multiple SQL Server tables using a T-SQL script, and how to check the existence of the table?<\/em><\/strong><\/h4>\n\n\n\n<p>To drop a table with a SQL Server script, simply use the DROP TABLE command. Indeed, the syntax of the MS SQL command to delete a table from a database is straight forward. Just remember to fill in the schema followed by the name of the SQL Server table in the case where a schema other that <em>dbo<\/em>, for database owner, is used.<\/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\/t-sql\/drop-a-table-with-a-sql-server-script\/#what-is-the-t-sql-drop-table-statement\" >What is the T-SQL DROP TABLE statement?<\/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\/t-sql\/drop-a-table-with-a-sql-server-script\/#use-case-1-drop-a-single-sql-server-table\" >Use Case 1: Drop a single SQL Server table<\/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\/t-sql\/drop-a-table-with-a-sql-server-script\/#use-case-2-drop-multiple-sql-server-tables\" >Use Case 2: Drop multiple SQL Server tables<\/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\/t-sql\/drop-a-table-with-a-sql-server-script\/#use-case-3-drop-a-table-if-it-exists\" >Use Case 3: Drop a table if it exists<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#use-case-4-drop-a-table-and-create-a-new-one\" >Use Case 4: Drop a table and create a new one<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#conclusion-on-dropping-tables-using-sql-server\" >Conclusion on dropping tables using SQL Server<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-what-is-the-t-sql-drop-table-statement\"><span class=\"ez-toc-section\" id=\"what-is-the-t-sql-drop-table-statement\"><\/span>What is the T-SQL DROP TABLE statement?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The DROP TABLE statement is a T-SQL statement used to delete a table from a database. It is a Data Definition Language (DDL) statement that permanently removes the table and all associated elements, including: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>data<\/li>\n\n\n\n<li>indexes<\/li>\n\n\n\n<li>triggers<\/li>\n\n\n\n<li>and constraints<\/li>\n<\/ul>\n\n\n\n<p>The syntax of the DROP TABLE statement is as follows:<\/p>\n\n\n\n<p><code><strong>DROP TABLE table_name;<\/strong><\/code><\/p>\n\n\n\n<p>Where <strong><em>table_name<\/em><\/strong> is the name of the table that you want to delete.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-case-1-drop-a-single-sql-server-table\"><span class=\"ez-toc-section\" id=\"use-case-1-drop-a-single-sql-server-table\"><\/span>Use Case 1: Drop a single SQL Server table<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The most common use case for the DROP TABLE statement is to delete a single table. To delete a table using the DROP TABLE statement, simply specify the name of the table that you want to delete. For example, suppose we have a table named &#8220;employees&#8221; that we want to delete. We can use the following T-SQL code to accomplish this:<\/p>\n\n\n\n<p>Here is a SQL script to <a href=\"https:\/\/expert-only.com\/en\/t-sql\/create-table-sql-server\/\">create a SQL Server table<\/a>, use it to have a sample table in the database. For example, let&#8217;s consider a table named dbo.SALES, and use this query to drop the table :<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DROP TABLE [dbo].[SALES]; <\/pre>\n\n\n\n<p>This will delete the dbo.SALES table and all associated data, indexes, triggers, and constraints.<\/p>\n\n\n\n<p>As no existence check is performed, if the SQL server displays this error, then the table doesn&#8217;t exist in the current <a href=\"https:\/\/www.britannica.com\/technology\/database\" target=\"_blank\" rel=\"noreferrer noopener\">database<\/a>.<\/p>\n\n\n\n<p><em>SQL Server Error:<br> \u00ab Msg 3701, Level 11, State 5, Line 1<br> Cannot drop the table \u2018SALES\u2019, because it does not exist or you do not have permission. \u00bb<\/em><\/p>\n\n\n\n<p>If you DROP a table from a SQL Server database and use directly the SQL command DROP TABLE followed by the table name. If the table does not exist, then the Microsoft Database Management System (RDBMS) is throwing an error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-case-2-drop-multiple-sql-server-tables\"><span class=\"ez-toc-section\" id=\"use-case-2-drop-multiple-sql-server-tables\"><\/span>Use Case 2: Drop multiple SQL Server tables<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In some cases, you may need to delete multiple tables at once. The DROP TABLE statement allows you to specify multiple tables in a single statement by separating them with a comma. For example, suppose we have two tables named &#8220;employees&#8221; and &#8220;departments&#8221; that we want to delete. We can use the following T-SQL code to accomplish this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DROP TABLE employees, departments;\n<\/pre>\n\n\n\n<p>This script will delete both the <em>employees<\/em> and <em>departments<\/em> tables and all associated data, indexes, triggers, and constraints, in one unique query. On the same, it is a good practice to check the existence of views before deleting them. <\/p>\n\n\n\n<figure class=\"wp-block-embed 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=\"WV9DFvTqYC\"><a href=\"https:\/\/expert-only.com\/en\/t-sql\/test-and-drop-a-sql-server-view-if-exists\/\">Test and drop a SQL Server view if it exists in the database<\/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;Test and drop a SQL Server view if it exists in the database&#8221; &#8212; SQL and IT Tutorials\" src=\"https:\/\/expert-only.com\/en\/t-sql\/test-and-drop-a-sql-server-view-if-exists\/embed\/#?secret=HV1xh8VdpA#?secret=WV9DFvTqYC\" data-secret=\"WV9DFvTqYC\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-case-3-drop-a-table-if-it-exists\"><span class=\"ez-toc-section\" id=\"use-case-3-drop-a-table-if-it-exists\"><\/span>Use Case 3: Drop a table if it exists<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes, you may want to delete a table only if it exists in the database. To do this, you can use the IF EXISTS clause with the DROP TABLE statement. For example, suppose we want to delete the &#8220;employees&#8221; table only if it exists. We can use the following T-SQL code to accomplish this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DROP TABLE IF EXISTS employees;\n<\/pre>\n\n\n\n<p>This will delete the &#8220;employees&#8221; table if it exists in the database. If the table does not exist, the statement will do nothing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-use-case-4-drop-a-table-and-create-a-new-one\"><span class=\"ez-toc-section\" id=\"use-case-4-drop-a-table-and-create-a-new-one\"><\/span>Use Case 4: Drop a table and create a new one<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In some cases, you may want to delete a table and create a new one with the same name and schema. To do this, you can use the DROP TABLE statement followed by the CREATE TABLE statement. For example, suppose we want to delete the &#8220;employees&#8221; table and create a new one with the same schema. We can use the following T-SQL script to accomplish these two tasks:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DROP TABLE IF EXISTS dbo.employees;\n\nCREATE TABLE dbo.employees (\n\tid INT PRIMARY KEY,\n\tname VARCHAR(50),\n\tage INT,\n\tsalary DECIMAL(10,2)\n);\n<\/pre>\n\n\n\n<p>This will delete the <strong><em>dbo.employees<\/em><\/strong> table if it exists and create a new one with the same name and schema.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion-on-dropping-tables-using-sql-server\"><span class=\"ez-toc-section\" id=\"conclusion-on-dropping-tables-using-sql-server\"><\/span>Conclusion on dropping tables using SQL Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In conclusion, this tutorial on how to drop a SQL Server table with a script shows that it is a powerful statement, frequently used to delete multiple tables from a database. It allows developers to delete single or multiple tables, delete a table if it exists, and delete a table and create a new one with the same schema.<\/p>\n\n\n\n<p>Note that it can easily integrated in a loop to drop all the table from a database. For example if combined with a <a href=\"https:\/\/expert-only.com\/en\/t-sql\/query-list-all-sql-server-tables\/\">query to list the tables<\/a>. <\/p>\n\n\n\n<p>As seen in the tutoriel , a good practice is to test the existence of the table using a simple SQL query. Use <a href=\"https:\/\/expert-only.com\/en\/t-sql\/check-if-table-exists-in-sql-server\/\">the SQL script example to check the existence before drop a table<\/a> using the EXISTS function. Here is another tutorial on how to manage SQL Server tables, is on <a href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-alter-table\/\">how to modify a SQL Server table<\/a> using the ALTER TABLE command.<\/p>\n\n\n\n<figure class=\"wp-block-embed 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=\"kmeZwpLYt6\"><a href=\"https:\/\/expert-only.com\/en\/t-sql\/check-if-table-exists-in-sql-server\/\">Check if table exists in SQL Server<\/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;Check if table exists in SQL Server&#8221; &#8212; SQL and IT Tutorials\" src=\"https:\/\/expert-only.com\/en\/t-sql\/check-if-table-exists-in-sql-server\/embed\/#?secret=gAxYDfcCyJ#?secret=kmeZwpLYt6\" data-secret=\"kmeZwpLYt6\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>How to drop one or multiple SQL Server tables using a T-SQL script, and how to check the existence of the table? To drop a table with a SQL Server script, simply use the DROP TABLE command. Indeed, the <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/\" title=\"How to drop a SQL Server table with a script?\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":10819,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[454],"tags":[],"class_list":{"0":"post-9462","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-t-sql"},"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>How to drop a SQL Server table with a script? T-SQL tutorials<\/title>\n<meta name=\"description\" content=\"How to drop a table with a SQL Server script? This example explains how to delete a MS SQL table from a database with the T-SQL DROP command.\" \/>\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\/t-sql\/drop-a-table-with-a-sql-server-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to drop a SQL Server table with a script?\" \/>\n<meta property=\"og:description\" content=\"How to drop a table with a SQL Server script? This example explains how to delete a MS SQL table from a database with the T-SQL DROP command.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/\" \/>\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=\"2022-05-13T04:06:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-10T09:12:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"How to drop a SQL Server table with a script?\",\"datePublished\":\"2022-05-13T04:06:00+00:00\",\"dateModified\":\"2023-03-10T09:12:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/\"},\"wordCount\":831,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg\",\"articleSection\":[\"T-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/\",\"url\":\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/\",\"name\":\"How to drop a SQL Server table with a script? T-SQL tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg\",\"datePublished\":\"2022-05-13T04:06:00+00:00\",\"dateModified\":\"2023-03-10T09:12:58+00:00\",\"description\":\"How to drop a table with a SQL Server script? This example explains how to delete a MS SQL table from a database with the T-SQL DROP command.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to drop a SQL Server table with a script?\"}]},{\"@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\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to drop a SQL Server table with a script? T-SQL tutorials","description":"How to drop a table with a SQL Server script? This example explains how to delete a MS SQL table from a database with the T-SQL DROP command.","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\/t-sql\/drop-a-table-with-a-sql-server-script\/","og_locale":"en_US","og_type":"article","og_title":"How to drop a SQL Server table with a script?","og_description":"How to drop a table with a SQL Server script? This example explains how to delete a MS SQL table from a database with the T-SQL DROP command.","og_url":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2022-05-13T04:06:00+00:00","article_modified_time":"2023-03-10T09:12:58+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg","type":"image\/jpeg"}],"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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"How to drop a SQL Server table with a script?","datePublished":"2022-05-13T04:06:00+00:00","dateModified":"2023-03-10T09:12:58+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/"},"wordCount":831,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg","articleSection":["T-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/","url":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/","name":"How to drop a SQL Server table with a script? T-SQL tutorials","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg","datePublished":"2022-05-13T04:06:00+00:00","dateModified":"2023-03-10T09:12:58+00:00","description":"How to drop a table with a SQL Server script? This example explains how to delete a MS SQL table from a database with the T-SQL DROP command.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/planning-4897792_1920x1080.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/t-sql\/drop-a-table-with-a-sql-server-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to drop a SQL Server table with a script?"}]},{"@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"}}]}},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/9462","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=9462"}],"version-history":[{"count":0,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/9462\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/10819"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=9462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=9462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=9462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}