Posts

VHD disk images being read while VirtualPC is not running?

I setup a Virtual PC recently and noticed my hard disks were very busy lately. My VirtualPC is not on, but checking what files were being accessed (Task Manager --> Performance --> Resource monitor) I noticed that the VHD virtual disk image was being read a lot. Which is really odd as it's not in use. The solution was to disble the service "Superfetch". Hey presto, all is quiet again. Superfetch was trying to keep my system running fast by pre-loading the VHD into memory. Madness. I've had superfetch turned off all day, and my hard disks's have never been so quiet. Wonderful. Now, if only there was a way to exclude folders from superfetch... Having a Google around there's no exclusion list, however, there is a way to refine what's going on via the registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters Modify the EnablePrefetcher key to one of the following settings: Disa...

HOWTO: Compress Virtual PC virtual hard disks (.VHDs)

If you use Virtual PC 2007 you know that the virtual hard drive files (.VHDs) can grow to extremely large sizes. The .VHD files dynamically expand when software is installed in the .VHD. After installation, the original setup files are deleted and no longer take up space in the .VHD. However the .VHD does not correspondingly dynamically shrink in size. Once a .VHD file expands - it doesn't shrink. EXAMPLE: If the installation of a product uses 500MB to expand its setup files and only really consumes 200MB in the "C:\Program Files\" directory, the .VHD file expands accordingly. When the 500MB of setup files are subsequently deleted after installation has completed, the .VHD file doesn't shrink afterwards. That is wasted host storage. So the question is: How do I shrink the size of a .VHD when I know it's inflated unnecessarily? Here's how to do it: Clear out the machine of filler Install ccleaner from http://ccleaner.com   which deletes all t...

SSMS handy short cut keys

Image
In Microsoft SQL Server Management Studio, its handy to have some short cut keys to do common tasks. One handy one I always use is to " select top 100 * from " as I like to highlight a table name and press CTRL+4 to get the top 100 rows instantly. To set this up, go to Tools->Options->Keyboard. And type "select top 100 * from " without the quotes and making sure you add a space after the from. Very important to leave a space at the end. Highlight a table and press Ctrl+4 and the top 100 rows will be shown. SSMS will run your command and append the highlighted text. If your table is called USERS, it would run "select top 100 * from USERS". If you forgot to leave a space at the end, it would try and run "select top 100 * fromUSERS" which won't work.

table-values functions. Make sure you write them as inline.

Here is a multi-line statement (slow): CREATE FUNCTION dbo.fnSomeReport ( @someParam INT , @field_company_id INT = NULL ) RETURNS @result TABLE ( [field_company_name] VARCHAR (255), [engineer] VARCHAR (100), [sku] VARCHAR (30) ) AS BEGIN INSERT INTO @result ( [field_company_name], [engineer], [sku] ) SELECT field_company_name, engineer, sku FROM ... WHERE ID > someParam AND (@field_company_id IS NULL OR field_company_id = @field_company_id) RETURN END GO Now as an inline statement (fast) CREATE FUNCTION dbo.fnSomeReport ( @someParam INT , @field_company_id INT = NULL ) RETURNS TABLE AS RETURN ( SELECT field_company_name, engineer, sku FROM ... WHERE ID > someParam AND (@field_company_id IS NULL OR field_company_id = @field_company_id) ) GO Right then whats going on and what the hell is all the fuss about anyway? The query optimizer expands the function as if it was a macro, and generates the plan as if you had provided the expanded query . Thus, there is no performance cost ...

PLINQO - Get it, use it, love it

I've stumbled across a LINQ to SQL extension called PLINQO freely downloadable at http://plinqo.com/ and includes source code. PLINQO is a set of CodeSmith templates that generates code for you around your LINQ to SQL DBML file. It generates Manager classes and Query classes automatically (it does this by looking at your primary keys, indexes and foreign key constraints). You must buy CodeSmith , which is the template engine, but PLINQO is free. Its actually quite amazing and saves you tons of time and energy creating boiler plate code. So glad I found it, now I want you to investigate it too. Go check out the video tutorials to see what I mean. Awesome .

Virtual Machine Key Combinations with Hyper-V

Taken from here and kept for prosperity incase the information was ever lost. So all credit for the following information goes to Ben Armstrong . Standard Windows Key combination Virtual Machine Connection Key Combination Explanation CTRL + ALT + DEL CTRL + ALT + END Displays the Task Manager or Windows Security dialog box on Windows (or logs in). ALT + TAB ALT + PAGE UP Switches between programs from left to right. ALT + SHIFT + TAB ALT + PAGE DOWN Switches between programs from right to left. ALT + ESC ALT + INSERT Cycles through the programs in the order they were started. CTRL + ESC ALT + HOME Displays the Windows Start menu. N/A CTRL + ALT + PAUSE Changes the Virtual Machine Connection window to / from full screen mode. N/A CT...

Execution of user code in the .NET Framework is disabled

I was testing our new SQL Server 2008 enterprise cluster today and managed to get the following SqlException running a C# application: "Execution of user code in the .NET Framework is disabled. Enable "clr enabled" configuration option. The statement has been terminated." The solution is to run the following: EXEC sp_configure 'show advanced options' , '1' ; go RECONFIGURE ; go EXEC sp_configure 'clr enabled' , '1' go RECONFIGURE ; -- Turn advanced options back off -- EXEC sp_configure 'show advanced options' , '0'; GO