Sql-Interview

SQL Interview: 60 Rowversion vs Timestamp

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 reviewing T-SQL code from an application.

You notice in the definition of some tables, the timestamp data type has been used. In other tables, the rowversion data type has been used for similar purposes.

2025-07-03

SQL Interview: 59 Schema Binding

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

Question:

You are reviewing T-SQL code from an application.

You notice that a view includes WITH SCHEMA_BINDING in its declaration.

What does that affect?

Answer:

Adding WITH SCHEMA_BINDING to a view definition ensures that the underlying objects (like tables) cannot be changed while the view exists.

2025-06-29

SQL Interview: 58 Trigger Firing 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: Administration Level: Advanced

Question:

If a SQL Server table has six triggers associated with it, what control do you have over the order that the triggers fire in?

Answer:

SQL Server doesn’t provide an option to control trigger firing order. However, it does provide an option to choose the first trigger to fire, and the last trigger to fire.

2025-06-25

SQL Interview: 57 Query Stuck

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:

The CPU of a SQL Server is at 2%. Very little I/O is happening.

A query has been running for a long time, and seems stuck i.e., doesn’t seem to be doing anything, what’s likely to be the issue?

2025-06-21

SQL Interview: 56 String Concatenation Operators

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:

You are writing Azure SQL Database code that needs to concatenate strings.

You have previously used the + operator to do this.

Which other operator can be used for concatenating strings?

Answer:

Azure SQL Database supports the double-pipe || operator for string concatenation.

2025-06-17

SQL Interview: 55 Nested Transactions

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:

You have code that uses transactions.

There is an outer transaction that contains an inner transaction.

If the inner transaction code executes a ROLLBACK, what is rolled back? Is it the inner transaction, the outer transaction, or both?

2025-06-13

SQL Interview: 54 Deadlock Correction

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

Question:

You have deployed a database application into production.

Soon after, you get reports that large numbers of deadlocks are occurring.

What is the most important first step in resolving deadlocks?

Answer:

While it might appear that looking into locking processes, etc. is critical, it is pointless reviewing these until you are certain that queries on the system are running efficiently.

2025-06-09

SQL Interview: 53 Dynamic SQL and Ownership Chaining

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

Question:

You have a table named Sales.Customers that is owned by dbo. You also have a stored procedure named Sales.FindCustomers that searches the Sales.Customers table.

A user Terry is given permission to the procedure and can successfully execute the procedure.

2025-06-05

SQL Interview: 52 Deleting duplicated rows

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 have an ETL process that loads employee details into a table named Staging.Employees. The table has the following columns:

  • EmployeeID (int)
  • FullName (nvarchar(100))
  • LoginName (varchar(100))

The table is a heap and has no primary key.

2025-06-01

SQL Interview: 51 Truncating datetime values to the minute

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

Question:

You are creating a view in a SQL Server based data warehouse.

You need to query transactions that include a TransactionDateTime column which uses the DateTime data type. The query is as follows:

2025-05-28