{"id":160,"date":"2018-06-05T20:23:13","date_gmt":"2018-06-05T20:23:13","guid":{"rendered":"http:\/\/dbtut.com\/?p=160"},"modified":"2019-10-31T14:30:23","modified_gmt":"2019-10-31T14:30:23","slug":"how-to-shrink-sql-server-data-file","status":"publish","type":"post","link":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/","title":{"rendered":"How To Shrink SQL Server Data File"},"content":{"rendered":"<p>I wanted to write this article because it has been mentioned in the topic &#8220;<a href=\"http:\/\/dbtut.com\/index.php\/2018\/06\/03\/how-to-shrink-sql-server-transaction-log\/\" target=\"_blank\" rel=\"noopener noreferrer\">How To Shrink SQL Server Transaction Log<\/a>&#8221; and there are some drawbacks in shrinking the data file.<\/p>\n<h2>Can We Shrink Data File in SQL Server<\/h2>\n<p>Yes you can shrink your data files. <strong>But you should not! <\/strong><\/p>\n<h2>What happens if we shrink data file in SQL Server?<\/h2>\n<p>If you shrink your data files, the index fragmantation in these files will grow very high. Not only non clustered index. This includes our clustered indexes in our tables.<\/p>\n<p>You may want to read the article titled &#8220;<a href=\"http:\/\/dbtut.com\/index.php\/2018\/06\/10\/difference-between-clustered-index-and-non-clustered-index\/\" target=\"_blank\" rel=\"noopener noreferrer\">Difference Between Clustered Index and Non Clustered Index<\/a>&#8221;<\/p>\n<h2>Instead of Shrinking Data File<\/h2>\n<p>Let me tell you something that happened recently. A friend created a table for testing in the X database in production environment and inserted 10 TB of data into the table. Yes 10 TeraByte. There are two things that can be done in such a situation.<\/p>\n<p><span style=\"background-color: #ff0000;\"><strong>Option 1)<\/strong> <\/span>Shrink all the data files in the filegroup where the table is created for testing purposes.<\/p>\n<p>As you guess, we didn&#8217;t do this.<\/p>\n<p><span style=\"background-color: #00ff00;\"><strong>Option 2) <\/strong><\/span>Create a new file group and move all indexes (Clustered-Non Clustered) in the file group to the new file group where we need to shrink.<\/p>\n<p>You can find the details of how to perform this in the article &#8220;<a href=\"https:\/\/dbtut.com\/index.php\/2018\/07\/28\/what-is-database-file-group-and-how-to-recreate-large-tables-in-another-file-group\/\" target=\"_blank\" rel=\"noopener noreferrer\">What is Database File Group And How To Recreate Large Tables In Another File Group<\/a>&#8220;.<\/p>\n<p>There is a very useful stored procedure called <code>sp_helpindex3<\/code> to be able to determine which index on which file group.<\/p>\n<p>You can create this stored procedure in the related database using the following script.<\/p>\n<pre class=\"\">SET ANSI_NULLS ON\nGO\nSET QUOTED_IDENTIFIER ON\nGO\nCREATE proc [dbo].[sp_helpindex3]\n--@objname nvarchar(776)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0-- the table to check for indexes\nas\nset nocount on\n\ndeclare @objname nvarchar(776),\n@objid int,\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0-- the object id of the table\n@indid smallint,\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0-- the index id of an index\n@groupid smallint,\u00a0 -- the filegroup id of an index\n@indname sysname,\n@groupname sysname,\n@status int,\n@keys nvarchar(2126),\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0--Length (16*max_identifierLength)+(15*2)+(16*3)\n@dbname sysname,\n@usrname sysname\n\n-- Check to see that the object names are local to the current database.\nselect @dbname = parsename(@objname,3)\nif @dbname is not null and @dbname &lt;&gt; db_name()\nbegin\nraiserror(15250,-1,-1)\nreturn (1)\nend\n\n\n-- create temp table\ncreate table #spindtab\n(\nusr_name sysname,\ntable_name sysname,\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\nindex_name sysname collate database_default,\nstats int,\ngroupname sysname collate database_default,\nindex_keys nvarchar(2126) collate database_default\u00a0 -- see @keys above for length descr\n)\n\n-- OPEN CURSOR OVER TABLES (skip stats: bug shiloh_51196)\ndeclare ms_crs_tab cursor local static for\nselect sysobjects.id, sysobjects.name, sysusers.name \nfrom sysobjects inner join sysusers on sysobjects.uid = sysusers.uid where type = 'U'\nopen ms_crs_tab\nfetch ms_crs_tab into @objid, @objname, @usrname\nwhile @@fetch_status &gt;= 0\nbegin\n\n\n-- Check to see the the table exists and initialize @objid.\n\/*\nselect @objid = object_id(@objname)\nif @objid is NULL\nbegin\nselect @dbname=db_name()\nraiserror(15009,-1,-1,@objname,@dbname)\nreturn (1)\nend\n*\/\n\n-- OPEN CURSOR OVER INDEXES (skip stats: bug shiloh_51196)\ndeclare ms_crs_ind cursor local static for\nselect indid, groupid, name, status from sysindexes\nwhere id = @objid and indid &gt; 0 and indid &lt; 255 and (status &amp; 64)=0 order by indid\nopen ms_crs_ind\nfetch ms_crs_ind into @indid, @groupid, @indname, @status\n\n\n\n\nwhile @@fetch_status &gt;= 0\nbegin\n\n-- First we'll figure out what the keys are.\ndeclare @i int, @thiskey nvarchar(131) -- 128+3\n\nselect @keys = index_col(@usrname + '.' + @objname, @indid, 1), @i = 2\nif (indexkey_property(@objid, @indid, 1, 'isdescending') = 1)\nselect @keys = @keys\u00a0 + '(-)'\nselect @thiskey = index_col(@usrname + '.' + @objname, @indid, @i)\nif ((@thiskey is not null) and (indexkey_property(@objid, @indid, @i, 'isdescending') = 1))\nselect @thiskey = @thiskey + '(-)'\n\n\n\nwhile (@thiskey is not null )\nbegin\nselect @keys = @keys + ', ' + @thiskey, @i = @i + 1\nselect @thiskey = index_col(@usrname + '.' + @objname, @indid, @i)\nif ((@thiskey is not null) and (indexkey_property(@objid, @indid, @i, 'isdescending') = 1))\nselect @thiskey = @thiskey + '(-)'\nend\nselect @groupname = groupname from sysfilegroups where groupid = @groupid\n\n\n-- INSERT ROW FOR INDEX\ninsert into #spindtab values (@usrname, @objname, @indname, @status, @groupname, @keys)\n\n\n\n-- Next index\nfetch ms_crs_ind into @indid, @groupid, @indname, @status\nend\ndeallocate ms_crs_ind\nfetch ms_crs_tab into @objid, @objname, @usrname\nend\ndeallocate ms_crs_tab\n\n\n\n-- SET UP SOME CONSTANT VALUES FOR OUTPUT QUERY\ndeclare @empty varchar(1) select @empty = ''\ndeclare @des1 varchar(35),\u00a0\u00a0\u00a0\u00a0\u00a0\n@des2 varchar(35),\n@des4 varchar(35),\n@des32 varchar(35),\n@des64 varchar(35),\n@des2048 varchar(35),\n@des4096 varchar(35),\n@des8388608 varchar(35),\n@des16777216 varchar(35)\n\nselect @des1 = name from master.dbo.spt_values where type = 'I' and number = 1\n\nselect @des2 = name from master.dbo.spt_values where type = 'I' and number = 2\n\nselect @des4 = name from master.dbo.spt_values where type = 'I' and number = 4\n\nselect @des32 = name from master.dbo.spt_values where type = 'I' and number = 32\n\nselect @des64 = name from master.dbo.spt_values where type = 'I' and number = 64\n\nselect @des2048 = name from master.dbo.spt_values where type = 'I' and number = 2048\n\nselect @des4096 = name from master.dbo.spt_values where type = 'I' and number = 4096\n\nselect @des8388608 = name from master.dbo.spt_values where type = 'I' and number = 8388608\n\nselect @des16777216 = name from master.dbo.spt_values where type = 'I' and number = 16777216\n\n\n-- DISPLAY THE RESULTS\nselect\n'usr_name'=usr_name,\n'table_name'=table_name,\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n'index_name' = index_name,\n'index_description' = convert(varchar(210), --bits 16 off, 1, 2, 16777216 on, located on group\ncase when (stats &amp; 16)&lt;&gt;0 then 'clustered' else 'nonclustered' end\n+ case when (stats &amp; 1)&lt;&gt;0 then ', '+@des1 else @empty end\n+ case when (stats &amp; 2)&lt;&gt;0 then ', '+@des2 else @empty end\n+ case when (stats &amp; 4)&lt;&gt;0 then ', '+@des4 else @empty end\n+ case when (stats &amp; 64)&lt;&gt;0 then ', '+@des64 else case when (stats &amp; 32)&lt;&gt;0 then ', '+@des32 else @empty end end\n+ case when (stats &amp; 2048)&lt;&gt;0 then ', '+@des2048 else @empty end\n+ case when (stats &amp; 4096)&lt;&gt;0 then ', '+@des4096 else @empty end\n+ case when (stats &amp; 8388608)&lt;&gt;0 then ', '+@des8388608 else @empty end\n+ case when (stats &amp; 16777216)&lt;&gt;0 then ', '+@des16777216 else @empty end\n+ ' located on ' + groupname),\n'index_keys' = index_keys\nfrom #spindtab\norder by table_name, index_name\nreturn (0) -- sp_helpindex\nGO\n<\/pre>\n<p>After doing this, there will be no data in the filegroup that we will shrink. So we can delete this filegroup.<\/p>\n<p>If the file group to be shrinked is a PRIMARY file group, we can not delete this file group.<\/p>\n<p>But now we can shrink because there is no user data in it.<\/p>\n<p><strong>As an important note<\/strong>, certainly do not open auto shrink in your databases.<\/p>\n<h2>Can we shrink MDF file?<\/h2>\n<p>Yes we can shrink. But first follow the steps I mentioned above. Move all user objects to another file group.<\/p>\n\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_160\" class=\"pvc_stats all  \" data-element-id=\"160\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I wanted to write this article because it has been mentioned in the topic &#8220;How To Shrink SQL Server Transaction Log&#8221; and there are some drawbacks in shrinking the data file. Can We Shrink Data File in SQL Server Yes you can shrink your data files. But you should not! What happens if we shrink &hellip;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_160\" class=\"pvc_stats all  \" data-element-id=\"160\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":11052,"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,"footnotes":""},"categories":[3],"tags":[2887,2890,5132,2889,2891,72,5097,74,73,71,69,70,5131,2892,2888],"class_list":["post-160","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-mssql","tag-can-we-shrink-data-file-in-sql-server","tag-can-we-shrink-mdf-file-sql-server","tag-can-we-shrink-mdf-file","tag-does-shrink-database-affect-performance","tag-how-do-i-shrink-the-size-of-my-database","tag-how-to-shrink-sql-server","tag-instead-of-shrinking-data-file","tag-move-tables-new-filegroup","tag-recreate-large-table-new-filegroup","tag-shrink-data-file","tag-shrink-sql-server","tag-shrink-sql-server-data-file","tag-shrinking-a-data-file-in-sql-server","tag-what-does-shrink-database-do","tag-what-happens-when-we-shrink-database"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Shrink SQL Server Data File - Database Tutorials<\/title>\n<meta name=\"description\" content=\"How To Shrink SQL Server Data File\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Shrink SQL Server Data File - Database Tutorials\" \/>\n<meta property=\"og:description\" content=\"How To Shrink SQL Server Data File\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/\" \/>\n<meta property=\"og:site_name\" content=\"Database Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-05T20:23:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-10-31T14:30:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-6.png\" \/>\n\t<meta property=\"og:image:width\" content=\"555\" \/>\n\t<meta property=\"og:image:height\" content=\"401\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"dbtut\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"dbtut\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/\"},\"author\":{\"name\":\"dbtut\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408\"},\"headline\":\"How To Shrink SQL Server Data File\",\"datePublished\":\"2018-06-05T20:23:13+00:00\",\"dateModified\":\"2019-10-31T14:30:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/\"},\"wordCount\":366,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-6.png\",\"keywords\":[\"Can we shrink data file in SQL Server?\",\"Can we shrink MDF file SQL Server?\",\"Can we shrink MDF file?\",\"Does shrink database affect performance?\",\"How do I shrink the size of my database?\",\"how to shrink sql server\",\"Instead of Shrinking Data File\",\"move tables new filegroup\",\"recreate large table new filegroup\",\"shrink data file\",\"Shrink sql server\",\"shrink sql server data file\",\"shrinking a data file in sql server\",\"What does shrink database do?\",\"What happens when we shrink database?\"],\"articleSection\":[\"MSSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/\",\"url\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/\",\"name\":\"How To Shrink SQL Server Data File - Database Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-6.png\",\"datePublished\":\"2018-06-05T20:23:13+00:00\",\"dateModified\":\"2019-10-31T14:30:23+00:00\",\"description\":\"How To Shrink SQL Server Data File\",\"breadcrumb\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#primaryimage\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-6.png\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-6.png\",\"width\":555,\"height\":401},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dbtut.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Shrink SQL Server Data File\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dbtut.com\/#website\",\"url\":\"https:\/\/dbtut.com\/\",\"name\":\"Database Tutorials\",\"description\":\"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux\",\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dbtut.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dbtut.com\/#organization\",\"name\":\"dbtut\",\"url\":\"https:\/\/dbtut.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"width\":223,\"height\":36,\"caption\":\"dbtut\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408\",\"name\":\"dbtut\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g\",\"caption\":\"dbtut\"},\"description\":\"We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.\",\"sameAs\":[\"http:\/\/NurullahCAKIR\"],\"url\":\"https:\/\/dbtut.com\/index.php\/author\/dbtut\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Shrink SQL Server Data File - Database Tutorials","description":"How To Shrink SQL Server Data File","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:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/","og_locale":"en_US","og_type":"article","og_title":"How To Shrink SQL Server Data File - Database Tutorials","og_description":"How To Shrink SQL Server Data File","og_url":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/","og_site_name":"Database Tutorials","article_published_time":"2018-06-05T20:23:13+00:00","article_modified_time":"2019-10-31T14:30:23+00:00","og_image":[{"width":555,"height":401,"url":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-6.png","type":"image\/png"}],"author":"dbtut","twitter_card":"summary_large_image","twitter_misc":{"Written by":"dbtut","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#article","isPartOf":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/"},"author":{"name":"dbtut","@id":"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408"},"headline":"How To Shrink SQL Server Data File","datePublished":"2018-06-05T20:23:13+00:00","dateModified":"2019-10-31T14:30:23+00:00","mainEntityOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/"},"wordCount":366,"commentCount":0,"publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-6.png","keywords":["Can we shrink data file in SQL Server?","Can we shrink MDF file SQL Server?","Can we shrink MDF file?","Does shrink database affect performance?","How do I shrink the size of my database?","how to shrink sql server","Instead of Shrinking Data File","move tables new filegroup","recreate large table new filegroup","shrink data file","Shrink sql server","shrink sql server data file","shrinking a data file in sql server","What does shrink database do?","What happens when we shrink database?"],"articleSection":["MSSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/","url":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/","name":"How To Shrink SQL Server Data File - Database Tutorials","isPartOf":{"@id":"https:\/\/dbtut.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#primaryimage"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#primaryimage"},"thumbnailUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-6.png","datePublished":"2018-06-05T20:23:13+00:00","dateModified":"2019-10-31T14:30:23+00:00","description":"How To Shrink SQL Server Data File","breadcrumb":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#primaryimage","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-6.png","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2018\/06\/Ads\u0131z-6.png","width":555,"height":401},{"@type":"BreadcrumbList","@id":"https:\/\/dbtut.com\/index.php\/2018\/06\/05\/how-to-shrink-sql-server-data-file\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dbtut.com\/"},{"@type":"ListItem","position":2,"name":"How To Shrink SQL Server Data File"}]},{"@type":"WebSite","@id":"https:\/\/dbtut.com\/#website","url":"https:\/\/dbtut.com\/","name":"Database Tutorials","description":"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux","publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dbtut.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/dbtut.com\/#organization","name":"dbtut","url":"https:\/\/dbtut.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","width":223,"height":36,"caption":"dbtut"},"image":{"@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dbtut.com\/#\/schema\/person\/fc047c39e1e53dce28fc4253529ea408","name":"dbtut","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c322c32021bf651d9e103b183963c479a9c9791ead0715f4348203496c39aa54?s=96&d=mm&r=g","caption":"dbtut"},"description":"We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.","sameAs":["http:\/\/NurullahCAKIR"],"url":"https:\/\/dbtut.com\/index.php\/author\/dbtut\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":0,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media\/11052"}],"wp:attachment":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}