Sql-Interview

SQL Interview: 26 Whole of data operations when adding columns in SQL Server

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 need to add additional columns to a table. You are concerned that you do not want to lock the table for long periods. You plan to avoid any operation that would rewrite every row i.

2025-03-15

SQL Interview 25: Extended Stored Procedures in SQL Server

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 stored procedures in the master database. You note both Stored Procedures, and Extended Stored Procedures. What is the difference between these types of procedures? Answer: Stored Procedures are written in T-SQL or SQL CLR and run in the standard user memory space of a SQL Server session.

2025-03-11

SQL Interview 24: DROP and CREATE vs ALTER for T-SQL Functions

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 script to change the code in a T-SQL function. You can choose to either DROP IF EXISTS and CREATE the procedure, or to use an ALTER statement. What advantage would you get from using an ALTER statement?

2025-03-07

SQL Interview 23: Logical issues related to ISNULL in SQL Server T-SQL

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: A query included within a stored procedure, has a predicate written like this: WHERE ISNULL(ProductSize, '') = ISNULL(@ProductSize, '') A problem has been identified with this predicate. The system needs to be able to differentiate between NULL values for product size and blank strings.

2025-02-23

SQL Interview 22: Working with Credentials in Azure SQL DB

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: Medium Question: With SQL Server on-premises, you can create a CREDENTIAL and they are stored in the master database. What option do you have with Azure SQL Database? Answer: You can create a DATABASE SCOPED CREDENTIAL in both SQL Server and in Azure SQL Database.

2025-02-21

SQL Interview: 21: Using ISNULL vs COALESCE

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: When writing T-SQL code, you often need to replace NULL values. The core two functions provided are ISNULL and COALESCE. What is the difference between them? Answer: ISNULL only takes a single value to check and replaces it when NULL.

2025-02-15

SQL Interview: 20: Difference between a login and a user

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: Intro Question: SQL Server can use both logins and users. What is the difference between them? Answer: A login provides access to the server, but not necessarily to any databases. A user is used to provide access to a database.

2025-02-11

SQL Interview: 19: Store why an index exists

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: While developers don’t mind adding indexes to a database, most people are very nervous about ever removing them. Tools let us see whether or not an index is being used, but it’s useful to know why the index was added in the first place.

2025-02-07

SQL Interview: 18: Table Truncation and Foreign Keys

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 two tables: dbo.Customers dbo.Orders The dbo.Orders table has a column CustomerID that is declared as a foreign key to the CustomerID column in the dbo.Customers table. In the dbo.Customers table, CustomerID is the primary key.

2025-02-06

SQL Interview: 17: Using NULLIF

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 see the following statement in a query that you are reviewing. What is the purpose of the NULLIF function in this statement? SELECT @a / NULLIF(@b, 0); What was the author trying to achieve?

2025-02-05