sql
You can subscribe to the sql tag micro-feed.
I was working on an issue where I needed to get data from about twenty instances of a database. The schema was very similar across all the databases, but each database was on a virtual machine on the network and had it’s own data. This is a legacy application that at some point in the […]
Making a disk larger on Azure is a simple process in the Azure portal. You just stop the machine, edit the disk, enter a new size and hit “Save”. When you try to make a disk smaller, though, you’ll be told “new disk size should be greater than 1024 GiB. Disks can only be resized […]
If you are looking after a database that has been haphazardly maintained in the past, you might come across inconsistent naming of things such as constraints. When you come to delete the existing one, it might be tricky if it doesn’t have the same name across environments. That’s when you need to do a lookup […]
Sometimes you want to generate an INSERT script from existing data, perhaps with one or two values tweaked. It’s a pain to hand-crank the INSERT when you can see exactly what you want using a SELECT statement. It’s also a bit long-winded to use SQL import/export wizards or other tools. Sometimes, you just want to […]
If you have been developing SQL Server databases for a while, you may remember performing neat tricks to implement paging. If you haven’t found it yet, there is a simple modern way to do paging in SQL Server that doesn’t require any tricks. For those who have used Linq in C#, you will have come […]
These notes will help you to easily collect an audit history on SQL Server tables. There are lots of ways to do this, including options that let you specify the exact table schema you want to use to track the history of changes, but this option is a neat way to get some robust tracking […]
I tuned into the Octopus Deploy and Clear Measure live stream on safe, automated, and drama-free database deployments and there was a flurry of really useful DbUp tips from Paul Stovell that I wanted to share. Use a sequential naming scheme Use a numbered naming scheme to ensure scripts are sequential on the file system. […]
If you attempt to create a user in SQL Server and get the following error: You can only create a user with a password in a contained database You probably didn’t quite configure your database as you intended. You can use the script below to fix it up (substitute DatabaseNameHere with your actual database name. […]
If you are working on an older application that has a lot of logic inside of the SQL database in jobs, procedures, and functions – you may find that your job schedules cause a repeating wave of SQL compilation peaks. If you suspect jobs may be the cause, you can use a query to find […]
Want to know who deleted rows from your SQL database? The script below joins up delete transactions with users in order to find out who just deleted something. Because this comes from the transaction log, you’ll only find stuff that is still available in there. This means it will be affected by retention/recovery modes. If […]