What is the key to automated database deployments?

In my blog post here https://the.agilesql.club/2019/06/what-steps-are-there-to-move-to-safe-automated-database-deployments/ I described the steps you need to go through so you can build up your confidence that you are capable of deploying databases using automation. I mean, afterall, knowing that it is possible to automate your deployments and having confidence that they will succeed are two very different things. Even with the best tooling in the world, automated database deployments are still a struggle and there is one key thing that you can do, no matter what tools you choose and that is to make the deployments re-runnable.

What steps are there to move to safe automated database deployments?

Database deployments are scary, you have all this data and if you drop the wrong table, run the wrong delete statement or have an error in a stored procedure that forgets to write that critical piece of data then you may never truly recover from that. You may well have backups but what if your backup is corrupt? What if your stored procedure hasn’t been writing the right data for a week?

How do you choose which columns to include in your SQL Server clustered index?

Database Engineering: Database Modelling: Do I need to have an incrementing identity int/bigint as my clustered index in a SQL Server database? When you want to produce a professional table design that will scale in the future and stop you being called at 4 AM to fix a performance issue, will you regret that decision to not add an incrementing “id” column to that core table? When you look in forums, do you see people fiercely guarding their opinion that you should/should not include an id column?

Why is my pivot query not returning any data? How to debug a PIVOT query

If you have a PIVOT query and it isn’t returning the data you expect, what can you do to troubleshoot it? The thing to do is to break it down into the constituent parts. First, lets take a look at a query and see what we can do to help. If you have this query: SELECT [1] AS Student1, [2] AS Student2, coalesce([3], 0) AS Student3 FROM (SELECT student_id, amount FROM [a]) as source PIVOT ( SUM(amount) FOR student_id in ([1],[2],[3]) ) as pv Step 1 - Do you have any actual data?

How to delete a lot of data from a SQL Server database

How to delete data efficiently When we delete data from a table in SQL Server, we can often find that the delete is slower than even the original insert, especially if the insert was made using the bulk insert API. Often when people find that they have a delete that is taking longer than it should and blocking other users, they kill the delete, but the rollback takes just as long if not longer than the delete up until that point.

How to load test a SQL database

How do you know whether a database code change is going to be great, okay or awful? If you want to test a new version of SQL Server how do you know whether to leave on or disable the legacy cardinality estimator? Will the latest cumulative update destroy the performance of your application? You don’t have to wait until production to know if the change you are going to do works or not and building a system to test the performance of your database is probably more straightforward than you realize.

Should I pluralize table names, is it Person, Persons, People or People?

Reading Time: 5 minutes (just do it!) There is a lot of confusion when it comes to designing tables in SQL Server around whether to pluralize names or not. How do you choose whether to pluralize or not? If we want to store a list of people and their details do we use “Person”, “Persons”, “People” or “Peoples”? Some people will use “People” and some will use “Person”, other persons or people would go for “Peoples” or “Persons”.

DacFx how to get the data type from a column a discussion of properties, relationships and the TSqlModel

Reading Time: 15 minutes (it is quite hard going, but you need to know this if you need to work with the DacFx) DacFx - Getting the data type of a column on a table, a rehash of an old blog post This post has been years in the making, I did a version of it years ago here: https://sqlserverfunctions.wordpress.com/2014/09/27/querying-the-dacfx-api-getting-column-type-information - well fast forward 5 years to now and I can now understand how it works and whereas before I basically sat in a debugger trying to figure out what method to use.

How can we merge multiple dacpacs into one

Reading Time: 4 minutes (not a minute longer) TLDR; You probably don’t want to actually merge dacpac’s you probably want to deploy multiple and use /p:IncludeCompositeObjects=true. If you do really want to merge dacpacs you can start with this sample: https://github.com/GoEddie/DacpacMerge Why? I was reading the dacfx issues on the dacextensions sample’s github site: https://github.com/Microsoft/DACExtensions/issues and one of the issues https://github.com/Microsoft/DACExtensions/issues/23 asked about how to merge dacpac’s and I have been asked a few times how to do this and I thought there was a sample but I couldn’t find it so I knocked a quick one up.

SSDT: Build in VSCode

Over the last couple of years I have been using VSCode more and more and Visual Studio less and less, this is great but there isn’t first class support for SSDT in VSCode, it would be great if there was but there isn’t today. This means I need to use Visual Studio to work with SSDT but often I find I just need to change a stored procedure or table and I don’t actually need the full SSDT experience, just a subset - can I change something and does it build, and can I deploy that build and run the tests?