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

Categories
SQL SQL Server

Renaming Tables in SQL Server

Renaming tables, that’s easy right? Renaming a Table Performing the rename of a table is straight forward in Management Studio via Object Explorer. You can simply select the table and right click and Rename (or press F2) and edit the name right there and then. Hit return and we’re good to go. If you’re scripting […]

Categories
SQL

Commenting with Care

Comments are a wonderful thing whether it’s keeping track of your thoughts in a drawn out stored procedure, or leaving some breadcrumbs to follow when revisiting code in the future. There is, however, a slightly uglier side to these when you’re trying to look at queries as they run. Let’s suppose we’re running a very […]