Azure-Sql-Db

SQL: DCL clauses in CREATE SCHEMA

SQL: DCL clauses in CREATE SCHEMA

Most people seem to be unaware that a CREATE SCHEMA statement can also include other DDL or DCL within it.

I’ve never been very keen on the option to add additional clauses in the CREATE SCHEMA statement as I’ve seen lots of issues when scripts are executed manually. You get a different outcome, depending upon how you execute it. For example, if you run statements in this script:

CREATE SCHEMA SomeSchema AUTHORIZATION Someone

CREATE TABLE Blah (Some table definition);

Where does the table Blah get created? Well, it depends.

2026-02-15

SQL: UPDATE against a table-valued function when declared inline

SQL: UPDATE against a table-valued function when declared inline

I had a discussion with a friend the other day who wouldn’t believe me that T-SQL allowed an UPDATE operation to be executed against a function in some situations. I must admit that when I first heard about it, it did my head in a bit as well, at least based on all I thought I knew about programming languages in general.

You can only perform an UPDATE against a table-valued function in T-SQL when the function was declared as an inline TVF. It still feels to me like it shouldn’t ever be permitted, but if you want to try it, here’s an example:

2026-02-13

SQL Down Under show 94 with guest Ben Weissman discussing vectors, REST, and AI in SQL Server 2025

SQL Down Under show 94 with guest Ben Weissman discussing vectors, REST, and AI in SQL Server 2025

It was great to catch up with Ben Weissman today and to have him on a SQL Down Under podcast.

Ben is a fellow Data Platform MVP.

Ben focusses on datawarehousing and analytics, still with a lot of on premises work but of course also Fabric / Azure work.

He has long experience with SQL Server, having started with SQL Server 6.5.

Ben says he loves to travel and loves food. He’s an author of books and video courses, and the organizer of data related events like Data Grillen, New Stars of Data, SQL Konferenz, and Data Saturday in both Vienna and Germany and other locations.

2026-02-11

SQL: Practical SQL Server Encryption - TDE, Always Encrypted, and When to Use Each

SQL: Practical SQL Server Encryption - TDE, Always Encrypted, and When to Use Each

Encryption in SQL Server is often discussed as a checklist item:

  • Is the database encrypted?
  • Do we need Always Encrypted?
  • What does compliance require?

What gets discussed far less often is how these features behave in real systems, what problems they actually solve, and what trade-offs they introduce.

This post looks at Transparent Data Encryption (TDE) and Always Encrypted from a practical standpoint: what each one protects, what it doesn’t, and how to decide which one belongs in your design.

2026-02-01

SQL: Common Anti-Patterns that Stop Parallelism

SQL: Common Anti-Patterns that Stop Parallelism

One of SQL Server’s greatest strengths is its ability to execute queries in parallel. When parallelism is available, the engine can divide work across multiple CPU cores and dramatically reduce query duration for large or complex workloads.

Yet in real systems, it’s surprisingly common to find queries that could run in parallel but don’t. The reason is often not hardware, configuration, or cost threshold settings — but query anti-patterns that quietly force the optimizer into a serial plan.

2026-01-26

Data Tales 13: The case of the invisible brake

Data Tales 13: The case of the invisible brake

This is the thirteenth tale in a series of stories about data. I hope you enjoy the series.

Today’s tale relates to a SQL Server system that had wonderful hardware, yet was unbelievably slow. Let’s discuss what happened.

Some background information

I had a call from the Microsoft office in Brisbane, Queensland, asking if I had time to look at a problem at a customer site. Both they, and the customer, had thrown considerable resources at trying to resolve a performance problem, but frustratingly, it persisted.

2026-01-24

SQL Interview: 104 Backup restore time

SQL Interview: 104 Backup restore time

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: Administration Level: Advanced

Question:

A database backup was started at 12:00 PM. It completed at 2:00 PM.

When the backup is restored, at what time point will the restored data be?

  • 12:00 PM
  • 2:00 PM
  • Somewhere between 12:00 PM and 2:00 PM

Answer:

2026-01-20

SQL Interview: 112 Trigger and constraint execution order

SQL Interview: 112 Trigger and constraint execution order

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: Development Level: Medium

Question:

You have tables that have both constraints and triggers. You need to explain the order of execution for these. Which execution order (from first to last), are used for:

  • Check constraints
  • After triggers
  • Instead of triggers

Answer:

2026-01-18

SQL Interview: 111 Simple recovery and log truncation

SQL Interview: 111 Simple recovery and log truncation

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: Administration Level: Advanced

Question:

If a database is configured for simple recovery model, what could stop the truncation of the transaction log being effective, and for the transaction log to keep growing in size?

Answer:

Here are the most frequent reasons:

2026-01-16

SQL Interview: 110 Long restores and restarts

SQL Interview: 110 Long restores and restarts

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: Administration Level: Intro

Question:

You are restoring a database backup. The restore finished reading pages 10 minutes ago, but the database still shows that it is restoring.

Can you speed up the restoring phase by restarting the server? If so, should you do that? If not, why not?

2026-01-14