Categories
T-SQL Tuesday

T-SQL Tuesday #146: Upending Preconceived Notions

This month’s invitation comes from Andy Yun who asked us to share something we’ve learned and which has subsequently changed our opinions. There were two immediate examples which came to mind, the first on a more technical note and the second somewhat more personal: “Table Variables Are Fast” Many years ago I’d found myself with […]

Categories
SQL

Introduction to Computed Columns

Using a computed column in a table allows you to have a calculation pre-baked into your schema. They also allow you to choose if you’d like that calculated value to be physically stored within the table (persisted) or to be calculated each time you query the table. To demonstrate this we’ll use a small sales […]

Categories
SQL

Deleting Data from a Heap

When it comes to removing data from a heap its pretty similar to removing it from a regular table: That’s all folks! Wait, or would you like your data pages back too? Yea, it might not be quite that easy… You see, when you remove a small number of records from a heap you’ll find […]

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 […]