SELECT
t.NAME AS TableName,
s.Name AS SchemaName,
p.rows AS RowCounts,
SUM(a.total_pages) / 125 AS TotalSpaceMB,
SUM(a.used_pages) / 125 AS UsedSpaceMB,
(SUM(a.total_pages) - SUM(a.used_pages)) / 125 AS UnusedSpaceMB
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN
sys.schemas s ON t.schema_id = s.schema_id
WHERE
t.NAME NOT LIKE 'dt%'
AND t.is_ms_shipped = 0
AND i.OBJECT_ID > 255
GROUP BY
t.Name, s.Name, p.Rows
ORDER BY
TotalSpaceMB desc
This blog is titled the way it is, because this is the method by which I came to learn most of the following information. 🤪
Friday, June 6, 2014
Determining the amount of space used by all tables in SQL Server
Wednesday, January 29, 2014
Improving bulk insert performance in Entity framework
Sometimes Entity Framework will have poor performance when inserting records. A possible workaround is to set the following flags:
This fix requires more research to determine if there are side-effects to setting these. If this is a shared context, then the flags should be set back to their original values after 'SaveChanges' has been called.
Note that this only works with DBContext,and not ObjectContext
yourContext.Configuration.AutoDetectChangesEnabled = false;
yourContext.Configuration.ValidateOnSaveEnabled = false;
This should be done before the calls to 'AddObject'. In my case, this reduced the time a piece of code took to process 2,000 records from 8 minutes down to about 10 seconds.This fix requires more research to determine if there are side-effects to setting these. If this is a shared context, then the flags should be set back to their original values after 'SaveChanges' has been called.
Note that this only works with DBContext,and not ObjectContext
Monday, January 6, 2014
Moving a Repository from SVN to Git on VisualStudio.com
- Create a new folder.
- Launch a Git Bash prompt and navigate to this folder.
- Use git to clone the SVN repository to this folder.
- git svn clone http://svn/repo/here/trunk (Taken from http://stackoverflow.com/a/79178/224531)
- This may take a while if there is a lot of history. But the end result is a stand-alone Git repo with all the history in it.
- Go the TFS site (visualstudio.com), and create a new project using Git as the source control.
- After this is created open the project and click on the 'Code' menu.
- It should show that the repository is empty. Follow the steps on this page, using the Bash command prompt, to attach the local repo to this new origin, and push the changes to the TFS site.
Friday, January 3, 2014
Fixing 500 Errors with IISExpress
When an app throws 500 errors in IIS Express with no additional debugging information, try the following:
- Close VS Studio - solution set with IISExpress
- Go to: /Document/IISExpress/config/ in your profile
- Rename or delete applicationhost.config
- Open your solution in VS Studio
- A dialog may fire up from IISExpress - this will set a fresh config.
- try to run your web app.
Wednesday, November 20, 2013
Fixing Screen Resolution in VirtualBox
Sometimes a virtual pc in VirtualBox will refuse to take up the whole screen. Even in Full-Screen mode, it will insist on showing things in a 1024x768 resolution. To fix this, you need to open a command prompt and run one of the following from c:\Program Files\Oracle\VirtualBox . This was taken from section 9.8.2 of the VirtualBox manual
VBoxManage setextradata global GUI/MaxGuestResolution anywill remove all limits on guest resolutions.VBoxManage setextradata global GUI/MaxGuestResolution >width,height<manually specifies a maximum resolution.VBoxManage setextradata global GUI/MaxGuestResolution autorestores the default settings. Note that these settings apply globally to all guest systems, not just to a single machine.
Tuesday, September 24, 2013
EF Empty Strings in Non-Nullable Fields
When using Entity Framework, sometimes it is desirable to have non-nullable string fields. The problem is that if the user leaves the field blank, EF will complain that a value is required in the field. To fix this, create a metadata class for the entity you are working with. Then decorate the field with this attribute:
This will allow you to save the entity with an empty string in this field.[DisplayFormat(ConvertEmptyStringToNull=false)]
Monday, September 23, 2013
Auto entering credentials in Git
Any time you do a Fetch or a Push to a secure Git repository, you will be asked for your username and password. To have these credentials auto-entered, do the following:
- Download got-credential-winstore. https://gitcredentialstore.codeplex.com/
- Put it in a folder where you will keep it permanently.
- Run it with the -i option to specify the Git location (not 100% sure this step is necessary.
- To use this in TortoiseGit, go to Settings/Credentials.
- Select 'wincred - this repository only'
Subscribe to:
Posts (Atom)