Sql-Interview

SQL Interview: 102 Checkpoint writes

SQL Interview: 102 Checkpoint writes

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:

When checkpoint writes occur, is only committed data written, or is uncommitted data written?

If only committed data, explain why.

If both, explain why.

Answer:

Checkpoint is a background process that:

  • Flushes dirty pages (pages in memory that have been modified since they were read from disk) to disk.
  • Records a log sequence number (LSN) in the transaction log that marks the point at which the database is known to be consistent on disk.

This means that SQL Server doesn’t flush only committed transactions — it flushes all dirty pages, whether the transactions that modified them are committed or not.

2025-12-28

SQL Interview: 114 master database

SQL Interview: 114 master 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: Administration Level: Advanced

Question:

You know that the master database in SQL Server is now separate to the resource database (mssqlsystemresource).

Can you list three types of instance-level metadata that still live in the master database?

Answer:

2025-12-27

SQL Interview: 101 Restoring successful backups

SQL Interview: 101 Restoring successful backups

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

Question:

If you have successfully created a SQL Server database backup, what could cause you to not be able to restore it, on the same server or another server ?

Answer:

A successful SQL Server backup does not guarantee that it can later be restored successfully. A few important points explain why:

2025-12-26

SQL Interview: 99 Table join order

SQL Interview: 99 Table join 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 are writing a query that involves inner joins across five tables. Does the order of the tables within the query affect the query plan?

Answer:

No. SQL Server determines the best order for you to join the tables in.

2025-12-21

SQL Interview: 115 Database information in master

SQL Interview: 115 Database information in master

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:

Most information about each database is stored within the database.

Can you list three types of database information that live in the master database?

Answer:

Pick three of the following:

  • Database IDs, names, creation date
  • Compatibility level
  • Collation
  • Recovery model
  • Status (ONLINE, RESTORING, SUSPECT)
  • File locations and size metadata (from sys.master_files)
  • Ownership (database owner)
  • Availability Group membership
  • Replication information
  • Database GUIDs, resource IDs

2025-12-20

SQL Interview: 98 Reading tables in non-clustered index order

SQL Interview: 98 Reading tables in non-clustered index 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:

If you are SELECTing from a table and the ORDER BY clause in your query is in the same order as a non-clustered index, will the non-clustered index be used?

Answer:

It might or it might not.

2025-12-19

SQL Interview: 97 Performance of well-formatted and laid-out SQL code

SQL Interview: 97 Performance of well-formatted and laid-out SQL code

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

Question:

A developer in your team has suggested that better formatted and laid-out SQL code will perform better?

Is this true?

Answer:

Because the optimiser reduces queries down to a format that it can work with the format of your code doesn’t make a difference. Better formatted code is more readable and maintainable though, so it’s always a good idea.

2025-12-17

SQL Interview: 96 Can an IDENTITY column contain duplicate values?

SQL Interview: 96 Can an IDENTITY column contain duplicate values?

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 created a table named dbo.Customers. The column CustomerID has been declared as

INT NOT NULL IDENTITY(1, 1)

No contraints are defined on the table.

Can the CustomerID contain a duplicate value? If so, how?

Answer:

2025-12-15

SQL Interview: 95 Are ISNULL and COALESCE the same for two parameters?

SQL Interview: 95 Are ISNULL and COALESCE the same for two parameters?

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:

If you have two values where you want to return the first if it’s not NULL, and otherwise return the second, is there any difference at all between using the ISNULL and COALESCE functions?

2025-12-09

SQL Interview: 94 SQL Server understanding of date strings

SQL Interview: 94 SQL Server understanding of date strings

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:

If you pass the following string to SQL Server, will it always reliably be understood as 7th October 2025 by the date, datetime, and datetime2 data types?

'2025-10-07'

If not, why not?

Answer:

No, while that is true for date, and datetime2, the value that will be cast for the datetime data type depends upon the regional settings. For example, in British English, a string in the format ‘XXXX-XX-XX’ will be read as ‘YYYY-DD-MM’.

2025-12-06