Skip to content

Data Storage

Little SQL Server Tricks: Increase the Font Size in the Result Grid of SSMS

The SQL Server Management Studio (SSMS) has a simple way to increase the font size of your query. (You can select a value between 20% and 400% in the bottom of that window). But when you try to increase the font size in the result grid, you find nothing. We always have to guess what it says when we share our screens in a Teams meeting. Luckily, someone in my team found the way to fix that problem.

Little SQL Server Tricks: Add New Columns With Default Value and Foreign Key

So far, I used separate statements to add a new column to a table, set a default value and add a foreign key relation to another table. However, we can do these 3 steps in one single command:

1
2
3
4
5
ALTER TABLE [Table Name] ADD
    [New Column Name] [Column Type] 
    CONSTRAINT [Constraint Name Default Value] DEFAULT ([Default Value]) NOT NULL,
    CONSTRAINT [Constraint Name Foreign Key] FOREIGN KEY ([New Column Name]) 
    REFERENCES [Other Table] ([Foreign Id])

How to Use DbUp Without Embedded Scripts

I use DbUp for all my database migrations. It is super simple and when something goes wrong, you can fix it without much effort. So far, I never had any problems with the embedded scripts approach as it is explained in the Getting Started section of the official documentation and in my blog post.

However, while trying to get Docker working with DbUp I noticed that I must do a lot of extra work when I need to create a separate DbUp image for every migration project I use. It would be much simpler when I could reuse my DbUp project and only replace the SQL scripts. Unfortunately, the embedded scripts approach requires a rebuild of the project and I am back at the beginning.

Little SQL Server Tricks: Creating a Range of Numbers

Some tasks I do in SQL Server would be much simpler if I could get a sequence or a range of numbers. I could create users#1 to user#1000 without any programming – just by using plain old SQL. PostgreSQL offers the generate_series function for such use cases. Unfortunately, there is nothing comparable in SQL Server. All you can find on Google are solutions that are complicated, long and impossible to remember.