Categories
SQL

An Unfortunate Tale of Clustering a Heap

If you’ve ran sp_BlitzIndex before you might have come across some warnings about self-loathing heaps and maybe you’re looking to put a clustering key on them. Generally that’s a good idea to consider but it can cause issues if the data needed to be in that specific order. In this instance it turned out there […]

Categories
SQL

Removing Duplicate Records from a Heap

Dealing with duplicate records can be a headache when you’re expecting them to be unique and at some point the application or report users start to question why they’re seeing the same customer or product appearing twice. Once you’ve tracked them down you typically want to get rid of them and sometimes you’ll find an […]

Categories
SQL T-SQL Tuesday

T-SQL Tuesday #143 – Short Code Examples

The ask this month is to share go-to short code snippets with the community. I think its right to start by showing appreciation for some of the widely adopted tooling in the community such as sp_WhoIsActive, the First Responder Kit, Ola’s Maintenance Solution and DbaTools. Without these available we wouldn’t have half the snippets and […]

Categories
SQL

Using Templates in Management Studio

We’ve all got those go-to queries – maybe its for the data warehouse where you need a dozen joins, or it could be that maintenance script where you need the parameters set in a specific way. They’ve been used so often we can either script them from memory or we know exactly where the scripts […]

Categories
PowerShell

Automating (and Debugging) File Downloads with PowerShell

If you’ve ever used PowerShell you’ll know how great it is for automating all those things you really don’t want to do more than once. Recently I needed to grab a file from a web page so we didn’t have folks to be downloading and copying it around manually. Its a super simple use case […]

Categories
SQL

Archiving Data with Delete and Output

Sometimes you find a large table where data is building up and the history is getting less relevant by the day. The size might be consuming valuable storage, increasing your backup window, maintenance window, or query run times (everyone uses a WHERE clause, surely?). It might have been around for a while and the creator […]

Categories
SSRS

Reporting Services Execution Logs

Within the Reporting Services tool there’s the ability to store execution logs when a report is ran. This can be particularly useful from an auditing perspective whether that be to see if reports are no longer in use, or if they contain some degree of sensitive information and want to understand who may have accessed […]

Categories
SSRS

Reporting Services Lookup Function

Reporting Services can be a useful tool to surface details for end users but sometimes you get a request to tag on some other data which isn’t contained within the same database or even environment. You could use cross database queries or linked servers respectively to get this data but it ends up building in […]

Categories
SQL Server

Moving Database Files between Drives

So you inherit a server and find the previous owners had left the default data and log folders on the C: drive and at the same time they managed to put half your databases are on the correct drives and the others were left getting cosy with your operating system. Thankfully remediation isn’t too painful […]

Categories
SSIS

Parsing High Precision Timestamps in SSIS

Being able to parse flat files is pretty standard work in SSIS but recently I came upon a situation when reviewing a package and there was something very strange happening with a timestamp being imported. Below you can see an example of the source file and its destination in the database. Clearly there’s something wrong […]