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