SQL Server check table fragmentation level

If you are using SQL Server, and discover that what should be a simple select query, or particularly multiple select queries that are unioned together with a sort are running slowly, then the issue is your table indexes. This is particularly the case when using Date and DateTime fields for sorting.

If you are trying to sort a table or multiple tables by Date, then it is a good idea to add an index on the Date column, it makes things significantly faster.

Here is the SQL Query to check all tables in your database and the levels of fragmentation of each:

SELECT dbschemas.[name] as 'Schema',
dbtables.[name] as 'Table',
dbindexes.[name] as 'Index',
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS indexstats
INNER JOIN sys.tables dbtables on dbtables.[object_id] = indexstats.[object_id]
INNER JOIN sys.schemas dbschemas on dbtables.[schema_id] = dbschemas.[schema_id]
INNER JOIN sys.indexes AS dbindexes ON dbindexes.[object_id] = indexstats.[object_id]
AND indexstats.index_id = dbindexes.index_id
WHERE indexstats.database_id = DB_ID()
ORDER BY indexstats.avg_fragmentation_in_percent desc

500 daily visitors!

500 Visitors a day!

Wow, what a milestone – my blog now receives over 500 unique visitors every day (well the vast majority of days anyway)! Its incredible to think that there is that much information on here that people find interesting!

The top post on my blog is (and has been for some time) Calibri and Cambria fonts for Mac, added back in 2013 as part of my move to the world of Mac. Since I moved to the world of brushed aluminium, I made the decision some 3 months later to move the software company I founded back in 2006 (ISArc) to now use everything Apple too. Its been a great journey, and the more we get into the world of Mac the more we find out new and interesting things about it. For example, did you know that pressing the Command + Up Arrow when in Finder takes you up a folder? So very, very useful to know! Moving to Mac’s brings with it several challenges, particularly when you get used to everything just working, most particularly when it comes to having to support older systems that we originally wrote in ASP.Net.

Our latest project is called Employability Support and is light-years ahead of where our systems would have been if we had stayed developing in the .Net environment mostly because of the wealth of technology out there that is now available that was not available for .Net. Our new systems use a great combination of PHP, JQuery and CSS to do all database calls asynchronously meaning a much better and smoother user experience.

My personal adventure in programming and computing continues and I am now involved in a local CoderDojo helping local kids to get inspired by technology and programming (and playing Minecraft). Its a great source of encouragement when you see 10 year olds writing mobile apps, and makes me realise just how important it is for me to stay up to date with technologies as they change.

Mac OS Console Error

I’ve just turned my iMac on this morning and am getting the following error repeating non-stop. I have Googled but cannot find any reference to it, so if you find this error because you are experiencing the same error, then please let me know if you find out a fix!

(com.displaylink.useragent[1644]) Service could not initialize: Unable to set current working directory. error=2, path=/System/Library/Extensions/DisplayLinkDriver.kext/DisplayLinkAgent: 14C1514: xpcproxy + 12907 [1227][63706214-56DC-3155-B46F-D4F21C9B1C0B]: 0x2

(com.displaylink.useragent) Service only ran for 0 seconds. Pushing respawn out by 5 seconds.


Screen Shot 2015-03-23 at 09.16.09

Reducing Sports Club Utility Costs

Today at the Rugby Club, Alistair Jinks shared some of the practical steps taken that may help other sports clubs to reduce their bills. The time of his example provided was a time of exceptional costs were being incurred prior to control being re-established.

The original £26k per annum utility costs were reduced to £12k per annum for the Rugby and Cricket Club!

Step One – Compare standing / connection utility charges, use and cost per unit with comparator clubs organisations.

Actions Taken


  • Access half hour usage data on line and understand opportunities to improve control e.g. limit use during expensive winter peak periods
  • Invest in LED lights prioritising heavy use areas. Pay back in replacing normal bulbs less than one year
  • 12 KW solar system (when ROCs subsidy applied) installed and is comfortably out performing projected pay back of 6 years
  • Fit timers to fridges in the bar
  • Get a better deal on the cost per unit by switching supplier if required


  • Read the meter regularly and understand use
  • Place locked control boxes over publically accessible controls
  • Limit time of shower and heating provision
  • Get a better deal on the cost per unit by switching supplier if required


  • Check meter to see if there is over night use after premises are closed.
  • If so identify driver.
  • Urinals may be faulty. A small run of water 24 hours a day adds up to a lot of use. Call plumber to fix.
  • Urinals may require tap fitted and discipline introduced to turn off supply when locking up at night, alternatively control sensors may  be installed if this can be afforded.
  • A leak may exist. Call plumber to locate fix.
  • External taps may be left running for long periods. Security taps can be fitted.
  • Connection charge challenged and verified as incorrect

Final Step – Establish metrics to measure use and cost . Tracking use is the more important. Present in power point graphs/ slides as a summary for Exec Committee and Treasurer to verify control established.