Azure-Sql-Db

SSMS Tips and Tricks 1-9: Turn off option to prevent saving changes that require table recreation

I don’t use the table designer in SQL Server Management Studio. Sorry, but I just don’t like it, or the options that it chooses for me. I’d rather use T-SQL every time, but I’m also the first to admit that there are plenty of people who would use that designer.

And when they do, many run into an error that says:

Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created.

2025-05-25

SQL Interview: 50 Using WHERE vs HAVING

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.

Section: Developer Level: Intro

Question:

You need to filter rows being returned by a query.

When should you use a HAVING clause rather than a WHERE clause?

Answer:

A WHERE clause is used to filter the rows from the source (usually a table).

2025-05-24

SSMS Tips and Tricks 1-8: Generate insert scripts that script data

Over the years, I’ve had a surprising number of questions on how to output all the data in a table as a series of INSERT statements. SQL Server Management Studio has had the ability to do this for a long time. Here’s an example.

In Object Explorer, I’ve expanded the WideWorldImporters database, then expanded Tables. Where people come unstuck is they right-click the table, and look at the scripting options:

2025-05-23

SSMS Tips and Tricks 1-7: Navigate as you type in sorted Object Explorer Details pane

I’ve mentioned a number of times how useful I think the Object Explorer Details panel is in SQL Server Management Studio.

One option in that panel that might not be so obvious is the sorted navigation. Here’s an example.

I’ve opened the WideWorldImporters database in Object Explorer, and clicked on the Tables node:

I then hit F7 to open the Object Explorer Details pane and clicked the Name heading to sort the table list. I like it ascending so you might need to click it twice:

2025-05-21

SQL Interview: 49 Index impacts on update operations

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.

Section: Administrator Level: Medium

Question:

You are considering adding an index to a table.

You have heard that adding indexes slows down UPDATE commands.

Does adding an index always slow down updates? If so, why? If not, why not?

2025-05-20

SSMS Tips and Tricks 1-6: Filters in Object Explorer

If you are working with databases with large numbers of objects, the contents of Object Explorer in SQL Server Management Studio can start to become a bit overwhelming. I wish it offered an option to group by schema. That would be helpful.

But you can at least filter by things like schema, when you need to work with a specific set of objects. You’ll notice that if you click on the database name, that the filter in the toolbar is grayed out, but if you click on a node below that like Tables, you can click on the toolbar filter icon. You can also right-click the node and choose to filter:

2025-05-19

SSMS Tips and Tricks 1-5: Extended properties for objects

I started working with SQL Server in 1992, but all through the 1980’s and 1990’s, I was also working with Progress 4GL. I thought it was the best of the character-based 4GLs but unfortunately, they did a poor job of migrating to Windows and we decided to stop using the product.

One thing that I used to love with Progress though is that the metadata for each column in the database was much richer than what is present in SQL Server. In fact, Microsoft Access was probably closer to it in that regard. It’s something I really missed when moving to SQL Server. In Progress, when I defined a column, I could also define things like:

2025-05-17

SQL Interview: 48 Enabling RCSI for a database

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.

Section: Administrator Level: Medium

Question:

Your database application has been suffering from signficant blocking issues.

One developer has suggested enabling RCSI for the database.

If you do that, what’s different about how the database would operate?

What code changes are needed to use it?

2025-05-16

SSMS Tips and Tricks 1-4: Add columns to Object Explorer Details

I’ve mentioned in an earlier article about scripting multiple objects at once, how useful the Object Explorer Details window is, and how little understood it is.

Another useful option in it, is that the displayed columns can be changed. In particular, you can add columns that would be useful. Let’s look at an example.

In Object Explorer, I’ve expanded the WideWorldImporters database and clicked on the word Tables:

Next, I hit the F7 key, and the Object Explorer Details pane opens showing this:

2025-05-13

SQL Interview: 47 Extracting hour from a datetime value

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.

Section: Developer Level: Intro

Question:

You need to extract the hour component from a datetime value.

Which function should you use?

Answer:

To do this in SQL Server, you should use the DATEPART function.

2025-05-12