{"id":17,"date":"2008-01-17T19:16:16","date_gmt":"2008-01-17T17:16:16","guid":{"rendered":"http:\/\/blog.eweibel.net\/?p=17"},"modified":"2008-01-17T19:23:38","modified_gmt":"2008-01-17T17:23:38","slug":"get-size-of-your-tables","status":"publish","type":"post","link":"https:\/\/blog.eweibel.net\/?p=17","title":{"rendered":"Get the size of your tables"},"content":{"rendered":"<p>Recently my boss asked me, why the databases (Microsoft SQL Server 2005) of our customers are so big. With the following SQL-Statements I could give more or less an answer to my boss.<\/p>\n<p><code>CREATE TABLE PW_SPACE(<br \/>\n\tname varchar(255),<br \/>\n\trows int,<br \/>\n\treserved varchar(255),<br \/>\n\tdata varchar(255),<br \/>\n\tindex_size varchar(255),<br \/>\n\tunused varchar(255)<br \/>\n)<br \/>\nGO<\/p>\n<p>EXEC sp_MSforeachtable @command1=\"INSERT INTO PW_SPACE EXEC sp_spaceused '?'\"<br \/>\nGO<\/p>\n<p>select * from PW_SPACE order by rows desc<br \/>\nGO<\/p>\n<p>select sum(rows) as Rows,<br \/>\nconvert(varchar(255), sum(convert(int, substring(data,0,len(data)-2)))) + ' KB' as Data,<br \/>\nconvert(varchar(255), sum(convert(int, substring(index_size,0,len(index_size)-2)))) + ' KB' as Indexsize<br \/>\nfrom PW_SPACE<br \/>\nGO<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently my boss asked me, why the databases (Microsoft SQL Server 2005) of our customers are so big. With the following SQL-Statements I could give more or less an answer to my boss. CREATE TABLE PW_SPACE( name varchar(255), rows int, reserved varchar(255), data varchar(255), index_size varchar(255), unused varchar(255) ) GO EXEC sp_MSforeachtable @command1=&#8221;INSERT INTO PW_SPACE EXEC sp_spaceused &#8216;?'&#8221; GO select * from PW_SPACE order by rows desc GO select sum(rows) as Rows, convert(varchar(255), sum(convert(int, substring(data,0,len(data)-2)))) + &#8216; KB&#8217; as Data,&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/blog.eweibel.net\/?p=17\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7],"tags":[],"class_list":["post-17","post","type-post","status-publish","format-standard","hentry","category-first-experiencies"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/plOV9-h","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1132,"url":"https:\/\/blog.eweibel.net\/?p=1132","url_meta":{"origin":17,"position":0},"title":"DataSet and deleted rows","author":"Patrick","date":"31. Jan 2012","format":false,"excerpt":"Yes, I know, the DataSet isn't the leading edge technology, but as the company where I work currently, there are several companies who use DataSet as data access technology. Recently, I had to migrate the DataSet subclasses of the framework of my current employer to .NET 4.0 and add LINQ\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/blog.eweibel.net\/?cat=13"},"img":{"alt_text":"Pair of cubic eggs","src":"https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/Fotolia_23504153_S_thumb.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1264,"url":"https:\/\/blog.eweibel.net\/?p=1264","url_meta":{"origin":17,"position":1},"title":"Migrate a VSS repository to TFS","author":"Patrick","date":"2. Aug 2012","format":false,"excerpt":"Recently I had to migrate parts from a Microsoft Visual SourceSafe 2005 repository to a Microsoft Team Foundation Server 2010 repository. In this blog post I show what I had to do and what the pitfalls were. The tool To migrate a repository you have at least two possibilities: Migrate\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/blog.eweibel.net\/?cat=13"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":160,"url":"https:\/\/blog.eweibel.net\/?p=160","url_meta":{"origin":17,"position":2},"title":"When to use stored procedures","author":"Patrick","date":"13. May 2009","format":false,"excerpt":"Recently I discussed with a colleague when to use stored procedures. As exptected it was quite a religious conversation. A few days later I found the following screencast: The Pros and Cons of Stored Procedures Based on the discussion and the screencast I tried to summarize my Pros and Cons:\u2026","rel":"","context":"In &quot;Good practices&quot;","block_context":{"text":"Good practices","link":"https:\/\/blog.eweibel.net\/?cat=5"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9,"url":"https:\/\/blog.eweibel.net\/?p=9","url_meta":{"origin":17,"position":3},"title":"Filtering on DataTables","author":"Patrick","date":"2. May 2007","format":false,"excerpt":"When you want to apply a filter to your datatable in your dataset, you can use the method Select on the class DataTable. In our current project we use this method very often, also for databinding. Recently I discover an unexpected behaviour. Let\u2019s assume, that our datatable has 4 datarows\u2026","rel":"","context":"In &quot;Good practices&quot;","block_context":{"text":"Good practices","link":"https:\/\/blog.eweibel.net\/?cat=5"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1198,"url":"https:\/\/blog.eweibel.net\/?p=1198","url_meta":{"origin":17,"position":4},"title":"Are stale data evil?","author":"Patrick","date":"27. Feb 2012","format":false,"excerpt":"When you're a software engineer who produces software for enterprises like banks or assurances, then it is normal you have huge databases (several gigabytes). Such systems have an operative application where users do the daily business of the company and there are more informative parts (or strategic parts) of the\u2026","rel":"","context":"In &quot;Software architecture&quot;","block_context":{"text":"Software architecture","link":"https:\/\/blog.eweibel.net\/?cat=4"},"img":{"alt_text":"Sexy young woman as devil in fire","src":"https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/Fotolia_37310173_S_thumb.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":942,"url":"https:\/\/blog.eweibel.net\/?p=942","url_meta":{"origin":17,"position":5},"title":"Enums and inheritance in .Net","author":"Patrick","date":"9. Feb 2011","format":false,"excerpt":"In one of my current projects I had the following code (I simplified the code a bit): public string ConnectionString { get { switch(this.Importer) { case Importer.SqlServer: return \"Server=localhost;Database=Northwind\"; case Importer.SqlServerOleDb: return\"Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind\"; default: throw new NotSupportedException( string.Format(\"Importer {0} is not supported yet.\", this.Importer)); } } } After running\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/blog.eweibel.net\/?cat=13"},"img":{"alt_text":"CodeCoverage","src":"https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/CodeCoverage_thumb.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/CodeCoverage_thumb.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/blog.eweibel.net\/wp-content\/uploads\/CodeCoverage_thumb.png?resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/posts\/17","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"}],"version-history":[{"count":0,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.eweibel.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}