September 4, 2018
Restoring a SQL Server Database

This is a simple guide to restoring a full backup file in SQL Server, covering a just a few options available during so. As always, have a read through Microsoft’s documentation page before-hand for proper info. 1. Open SSMS and connect to your SQL Server. 2. Right click Databases and select Restore Database. 3. Select […]

August 30, 2018
Batch Deletions in SQL Server

This script will delete rows within a table that are out-with the specified retention period. This can be useful if you’re running deletes on large tables, and particularly if; #- Deletes are taking a long time & you’re finding it difficult to track progress. #- You have a short maintenance window each day to perform […]

July 9, 2018
Copying Dates into Excel

There’s often a need to quickly copy/paste a database query output into an Excel sheet, rather than exporting as a .csv file. When you do this for a DATETIME column though, it’ll show up in Excel looking something like this. I don’t think Excel likes the milliseconds. This is the data I tried to copy […]

July 8, 2018
Stack Exchange Data Explorer

The Stack Exchange Data Explorer is an amazing place where you’ll find all the data that is stored for those Q&A’s they’ve got going. The interesting stuff is down here though 😉 (number 24 in the list) You can view other folk’s queries on each database, as well as create a query of your own… […]

July 1, 2018
More on SPIDs… and Killing Them

Something I learned today while looking at an old script. The script kills all SPIDs on a database. I had an instant urge to kill system SPIDs just to see what would happen. And the result was… That’s a good thing though right? One less thing to be worrying about. You can’t kill system SPIDs. […]

June 30, 2018
Change Highlighted Colour of Text in WordPress

This is one from my fix list as the default highlighted text colour on my theme was green. A quick Google search showed me the way. To make the change, I had to add the following to my theme's stylesheet. There are many WordPress plugins that will allow you to change this. Some will also […]

June 18, 2018
SQL Server Support

What’s the plan when you don’t know how to fix a production issue? You can prepare this situation by reading and keeping up to date. But when you’re sweating behind a keyboard, you haven’t moved out your chair for 4 hours and you’re being chased for an update, what do you do?... I thought I'd […]

May 21, 2018
Logging sp_whoisactive to a table

This is a follow-on post of sp_who, sp_who2 & sp_whoisactive and is a run-through of logging SQL activity to a table. Even if you are equipped with a SQL Server monitoring tool, you still may be having trouble finding that slow/blocking query that runs during the night. Running sp_whoisactive periodically (e.g. every 30/60 seconds) and […]

May 21, 2018
sp_who, sp_who2 & sp_whoisactive

Sp_whatnow? sp_who, sp_who2 and sp_whoisactive are stored procedures that allow you to view current users, sessions, and processes within a SQL Server instance. You'd want to see this for identifying things like blocking or checking general activity. sp_whoisactive is definitely one of my favourite stored procedures. Created by Adam Machanic, this tool gives you an […]

May 19, 2018
Geographical Spatial Environmental Mental

The title is just words thrown together. I'm glad you noticed. This post is the start of a "Study Blog" category, which is more or less a scribble pad for when I'm watching a video or reading stuff. My thoughts recently have been with the 70-461 Querying Microsoft SQL Server 2012/2014 exam. I was converted […]

May 16, 2018
Show Line Numbers in the SSMS Query Window

This is a tip on how to show line numbers in your SQL Server Management Studio (SSMS) query window. This can be useful for when you receive an error with reference to a line in your code, although it’s not a necessity having it enabled as you’ll see below. I’ve created a simple script to […]