Microsoft certification · Exam DP-800

DP-800 Mock Exam Page 2

Developing AI-Enabled Database Solutions

Free DP-800 mock exam questions 11–20, each with the answer and an explanation.

20 questions · 34 minutes · free, no sign-up

Free DP-800 questions

11–20 of 26 free
Question 11 Choose 1
You have an Azure SQL database that contains a table named Rooms. Rooms was created by using the following transact-SQL statement.

You discover that some records in the Rooms table contain NULL values for the Owner field. You need to ensure that all future records have a value for the Owner field. What should you add?
Show answerHide answer

Correct answer: B a check constraint

Explanation

Explanation:

This question tests how to enforce data integrity rules on a specific column in an existing table. The requirement is to ensure that all future records have a value for the Owner field, meaning NULL values must be rejected during insert or update operations. The solution must restrict data entry without altering the column's data type or dropping the table.

✔️ Correct Option:

B. a check constraint
A check constraint enforces logical data integrity by evaluating a Boolean expression on inserted or updated rows. By adding a check constraint such as CHECK (Owner IS NOT NULL), you ensure that any future attempts to insert or update a record without an Owner value will fail and be rejected. This perfectly aligns with the requirement to enforce a value for the Owner field going forward.

❌ Incorrect Options:

A. a foreign key
A foreign key is used to enforce referential integrity between two tables, ensuring that a value in one table matches a value in another table's primary or unique key. It does not validate whether a column contains NULL values and is unrelated to the specific requirement of forcing data entry for a single column.

C. a nonclustered index
A nonclustered index is a performance optimization structure that speeds up data retrieval for queries. It does not enforce any data validation or integrity rules. Adding one will not prevent NULL values from being inserted into the Owner column.

D. a unique constraint
A unique constraint enforces that all values in a column or set of columns are distinct. It does not prevent NULL values; in fact, in SQL Server, a unique constraint typically allows a single NULL value (or multiple, depending on how it is defined). It cannot guarantee that every record has a value.

🔧 Reference:
→ Unique constraints and check constraints — Confirms that check constraints enforce domain integrity by limiting the values that can be placed in a column, such as restricting NULL values.

→ CREATE TABLE (Transact-SQL) — Explains how to define and add constraints to tables to enforce data validity.
Question 12 Choose 1
You have an SDK-style SQL database project stored in a Git repository. The project targets an Azure SQL database.
The CI build fails with unresolved reference errors when the project references system objects.
You need to update the SQL database project to ensure that dotnet build validates successfully by including the correct system objects in the database model for Azure SQL Database.
Solution: Add the Microsoft.SqlServer.Dacpacs.Azure.Master NuGet package to the project.
Does this meet the goal?
Show answerHide answer

Correct answer: A Yes

Explanation

Explanation

This question tests how to resolve unresolved reference errors for system objects in an SDK-style SQL database project that targets Azure SQL Database. SQL projects do not include system objects in the database model by default. The fix is to add a database reference that contains the correct system database schema for the target platform.

Correct Answer: ✅ A. Yes

✅ A. Yes
The Microsoft.SqlServer.Dacpacs.Azure.Master NuGet package contains the dacpac for the Azure SQL Database master system objects. Adding it as a package reference puts those objects into the database model, so references to them resolve during dotnet build validation. Because the project targets Azure SQL Database, this is the correct platform specific package, and the solution meets the goal.

❌ B. No
No would be correct only if the package did not match the target platform or did not supply the missing objects. For example, Microsoft.SqlServer.Dacpacs.Master is for SQL Server, not Azure SQL Database. Here the Azure specific package is used, so the solution does include the correct system objects and does meet the goal.

🔧 Reference
🔗 SQL projects system objects – Microsoft Learn → confirms that SQL projects exclude system objects by default and that the Azure SQL Database master package is added as a package reference.

🔗 SQL projects package references – Microsoft Learn → confirms that system database schemas are published as NuGet database reference packages for use in SDK-style SQL projects.
Question 13
You have a SQL database in Microsoft Fabric that contains the following functions:
• A multi-statement table-valued function (TVF) named sales.mstvf_orderStatus() that returns order status information
• A scalar user-defined function (UOF) named dbo.ufn_GetlaxMultiplier(^rax/Wt money,
gStateCode char(2)) that returns a numeric multiplier used in tax calculations Reporting queries frequently join Sales.«istvf_OrderStatus() to a table named Sales.SalesOrderHeader and return large result sets. A performance review shows that the queries produce inconsistent execution plans.
During a code review, a developer discovers that the following Transact-SQL statement produced an error.

Show answerHide answer

Explanation



Explanation:

This question tests your understanding of T-SQL user-defined functions, specifically the rules for determinism, the performance differences between Multi-Statement Table-Valued Functions (MSTVFs) and Inline TVFs, and the mandatory syntax for invoking scalar functions. The scenario highlights an execution error in a scalar function call and inconsistent execution plans caused by an MSTVF join.

✔️ Correct Option:

Statement 3 (Yes):
Replacing ufn_GetTaxMultiplier with dbo.ufn_GetTaxMultiplier in the EXEC function statement will resolve the error. In SQL Server and Microsoft Fabric, scalar user-defined functions must be invoked using at least a two-part name (schema.function_name). The original statement lacked the schema prefix, which is the exact cause of the execution error. Adding dbo. correctly resolves the function name and fixes the issue.

❌ Incorrect Options:

Statement 1 (No):
You cannot use GETDATE() in dbo.ufn_GetTaxMultiplier to produce nondeterministic results. While GETDATE() is a nondeterministic function, its inclusion does not "produce" nondeterministic results in a way that fixes an error or is the intended design here. Furthermore, the error in the code is a syntax/resolution error (missing schema), not an issue with function determinism.

Statement 2 (No):
Rewriting Sales.mstvf_OrderStatus() as an inline TVF will not reduce the number of inconsistent execution plans. Inline TVFs allow the query optimizer to expand them into the outer query, which generally improves cardinality estimation and results in more stable and consistent execution plans compared to MSTVFs. Therefore, the statement's claim is logically inverted and incorrect.

🔧 Reference:
→ Execute user-defined functions - Confirms that scalar functions must be invoked using a two-part name (schema.function).

→ Create Table-Valued Functions - Explains how inline TVFs provide better optimization and stable execution plans compared to multi-statement TVFs.
Question 14 Choose 1
You have an Azure SQL table that contains the following data.

You need to retrieve data to be used as context for a large language model (LLM). The solution must minimize token usage. Which formal should you use to send the data to the LLM?

Show answerHide answer

Correct answer: A Option A

Explanation

Explanation

This question tests how to prepare relational data as context for a large language model when token usage must be kept low. Every field sent to the model consumes tokens, so only the fields that help the LLM understand and answer should be included. A key such as FaqId is useful inside the database but adds no meaning for the model, while the product name, question, and answer carry the real context.

✅ A. JSON array with ProductName, Question, and Answer for each row
Option A sends only ProductName, Question, and Answer for each row. These three fields give the LLM everything it needs to know which product the answer belongs to and what was asked. It leaves out FaqId, a database key that carries no meaning for the model, so every row uses fewer tokens while the context stays complete, relevant, and accurate.

❌ B. JSON array with only a Prompt property containing the answer text
Option B keeps only the answer text under a Prompt property. It is compact, but it removes the product name and the original question. Without them the LLM cannot tell which product an answer describes or what it responds to, so the context becomes ambiguous. Losing essential meaning to save tokens is not acceptable.

❌ C. JSON array with FaqId, Question, and Answer for each row
Option C includes FaqId, Question, and Answer but drops ProductName. The question text alone, such as asking about a stylus, does not say which product it refers to, so the LLM cannot link the answer to the right item. It also spends tokens on FaqId, an identifier that adds no value for the model.

❌ D. JSON array with FaqId, ProductName, Question, and Answer for each row
Option D contains every column, including FaqId and ProductName. The product context is preserved, but FaqId is a database identifier that the LLM does not need. Including it in each row adds extra tokens without improving understanding, so this format is not the most efficient choice when token usage must be minimized.

🔧 Reference
🔗 Format query results as JSON with FOR JSON – Microsoft Learn → confirms that each row becomes a JSON object and each selected column becomes a property, so choosing only the needed columns controls the size of the output.
Question 15
You have an Azure SQL database that supports an OLTP application.
You need to write Transact-SQL code that returns blocking chain details. The output must return only sessions that ate blocked or are blocking other sessions.
How should you complete the code? To answer, drag the appropriate values to the correct targets. Each value may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content NOTE: Each correct selection is worth one point.
Show answerHide answer

Explanation



Explanation:

This question tests the ability to write a diagnostic Transact-SQL script for monitoring and analyzing blocking chains in an Azure SQL database using dynamic management views (DMVs). Specifically, the query constructs a common table expression (CTE) named cteBL to aggregate blocked session IDs hierarchically using XML path concatenation, pairs session states with sys.dm_exec_sessions and sys.dm_exec_requests, and extracts current SQL statement texts and input buffers using sys.dm_exec_sql_text and sys.dm_exec_input_buffer.

Correct Options:

✅ FROM sys.dm_exec_requests (Target 1):
This is required inside the CTE subquery to inspect current request-level blocking metadata, specifically tracking blocking_session_id to identify which sessions are blocking others.

✅ LEFT OUTER JOIN sys.dm_exec_requests (Target 2):
A left outer join is necessary in the main query because sessions that are blocking others might not currently have an active request (sys.dm_exec_requests row), but must still be returned if they hold active blocking locks.

✅ OUTER APPLY sys.dm_exec_sql_text(r.sql_handle) (Target 3):
An outer apply with sys.dm_exec_sql_text retrieves the Transact-SQL text batch associated with the active request's execution handle.

✅ OUTER APPLY sys.dm_exec_input_buffer(s.session_id, NULL) (Target 4):
An outer apply with sys.dm_exec_input_buffer fetches the last submitted input statement buffer for the given session ID (s.session_id), passing NULL for the optional request ID parameter.

Incorrect options:

❌ FROM sys.dm_tran_locks / INNER JOIN sys.dm_tran_locks:
These refer to lock-level granularity rather than request-level session blocks (blocking_session_id), making them incorrect for building session-based blocking chain hierarchies in this context.

❌ CROSS APPLY sys.dm_exec_sql_text (r.sql_handle):
Using an inner cross apply would filter out sessions lacking an active request handle, omitting idle sessions that are acting as root blockers.

❌ OUTER APPLY sys.dm_exec_input_buffer(r.session_id, 0):
Referencing r.session_id instead of session-level s.session_id can fail or omit sessions that do not have a currently active request row in sys.dm_exec_requests.

Reference:
⇒ Microsoft Learn: sys.dm_exec_requests (Transact-SQL) confirms how to query request and blocking session identifiers.
Question 16 Choose 1
Your development team uses GitHub Copilot Chat in Microsoft SQL Server Management Studio (SSMS) to generate and run Transact-SQL queries against an Azure SQL database named DB1 DB1 contains tables that store sensitive customer data.
You need to ensure that any Transact SQL queries that run from GitHub Copilot Chat In SSMS are restricted by the same permissions as the developer's database login.
What prevents the GitHub Copilot Chat-run queries from accessing data beyond the developer's access?
Show answerHide answer

Correct answer: B GitHub Copilot Chat runs queries by using the developer's database identity and permissions.

Explanation

Explanation:

GitHub Copilot Chat in SSMS executes generated T-SQL queries under the security context of the developer's database login. SQL Server enforces the permissions assigned to that login, preventing Copilot from accessing data or performing operations that the developer is not authorized to perform.

🟢 Correct Option:

B. GitHub Copilot Chat runs queries by using the developer's database identity and permissions.
GitHub Copilot Chat uses the authenticated developer's database identity when executing queries. It does not have separate or elevated database permissions. If the developer cannot access a particular table because they lack the required permissions, Copilot cannot access it either. This ensures that database security rules remain enforced during AI-assisted query execution and protects sensitive customer data from unauthorized access.

🔴 Incorrect Options:

A. GitHub Copilot Chat runs queries in a read-only sandbox that is isolated from production database permissions.
Copilot does not rely on an isolated sandbox to enforce database access permissions. Its queries execute against the connected database using the configured execution identity. Database permissions, rather than sandbox isolation, determine which data can be accessed.

C. GitHub Copilot Chat filters query results on the client side to remove rows the developer is unauthorized to see.
Copilot does not depend on client-side filtering to protect sensitive information. Access restrictions are enforced by SQL Server during query execution. Unauthorized data cannot be accessed simply because Copilot filters the returned results afterward.

D. GitHub Copilot Chat uses different row-level security (RLS) policies than the developer.
Copilot does not use separate RLS policies. It executes queries under the developer's database identity, so the database's existing security policies, including applicable row-level security rules, continue to apply.

🔧 Reference:
1. ⇒ Execution context for GitHub Copilot in SQL Server Management Studio
Confirms that Copilot executes queries using the connected user's login and permissions without granting elevated access.

2. ⇒ Use the GitHub Copilot Chat experience in SQL Server Management Studio
Explains how Copilot-generated queries use the user's login and permissions when accessing a database.
Question 17
You have an Azure SQL database that contains a table named dbo.Orders. You have an application that calls a stored procedure named dbo.usp_tresteOrder to insert rows into dbo.Orders. When an insert fails, the application receives inconsistent error details. You need to implement error handling to ensure that any failures inside the procedure abort the transaction and return a consistent error to the caller. How should you complete the stored procedure? To answer, drag the appropriate values to the correct targets, tach value may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content. NOTE: Each correct selection is worth one point.

Show answerHide answer

Explanation



Explanation

This question tests how to build reliable error handling inside a stored procedure that inserts data and returns a value to the caller. A TRY...CATCH block must capture any failure, undo the open transaction so no partial work remains, and then pass the original error back to the application. The procedure must also return the new identity value through the OUTPUT parameter after a successful insert.

✅ Blank 1: SET @OrderId = SCOPE_IDENTITY()
Blank 1 uses SET @OrderId = SCOPE_IDENTITY(). Right after the INSERT, SCOPE_IDENTITY returns the identity value generated in the current scope, so the new order key is stored in the OUTPUT parameter and returned to the application. It runs before COMMIT, which keeps it inside the transaction, and it is safer than @@IDENTITY because triggers cannot change the value returned to the caller.

✅ Blank 2: IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
Blank 2 uses IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION. Inside the CATCH block, the code first checks whether a transaction is still open, then rolls it back so no partial data remains. The check prevents an error if the transaction was already closed. Rolling back before THROW ensures the failure aborts the transaction and the caller then receives the original error consistently.

❌ BEGIN CATCH
BEGIN CATCH is already present in the procedure as the line that opens the CATCH block. Using it again in a blank would nest an invalid CATCH start inside the code and cause a syntax error. It is a block keyword, not a statement that sets the output value or rolls back the transaction.

❌ RAISERROR(‘CreateOrder failed’, 16, 1)
RAISERROR(‘CreateOrder failed’, 16, 1) returns a fixed custom message and replaces the original error details such as the number, line, and message. That would hide the real cause. The requirement is a consistent error for the caller, and the procedure already uses THROW to rethrow the original error, so RAISERROR is not needed.

❌ ROLLBACK TRANSACTION
A plain ROLLBACK TRANSACTION in the CATCH block would fail with an error if no transaction is active, because it does not check the transaction count first. The unconditional form is less safe than the guarded check. It also has no role in setting the OUTPUT parameter, so it does not fit the first blank.

❌ THROW
THROW is already written after the blank inside the CATCH block, where it rethrows the original error to the caller. Adding another THROW in the blank would run before the rollback and stop execution, so the transaction would stay open. It also cannot assign the new identity value to the OUTPUT parameter.

🔧 Reference
🔗 Handle errors with TRY...CATCH – Microsoft Learn → confirms that @@TRANCOUNT should be checked before ROLLBACK TRANSACTION in a CATCH block, and that THROW re-raises the error to the caller.
Question 18 Choose 1
Vou have a SQL database in Microsoft Fabric that contains a nvarchar(max) column named MessageText. An ID is always contained within the first paragraph of MessageText. You need to write a Transact SQL query that uses REGEXP_SUBSTR to extract the ID from MessageText.
What should you include in the query?
Show answerHide answer

Correct answer: B Cast Messagelext to nvarchar(4000) before calling REGEXP SUBSIR.

Explanation

Explanation:

The question tests how to prepare a large text column for regular expression processing in T-SQL. Casting changes the input data type and limits the text passed to the extraction function. However, the current Microsoft documentation also describes support for nvarchar(max) inputs up to 2 MB, which makes this question potentially outdated.

🟢 Correct Option:

B. Cast MessageText to nvarchar(4000) before calling REGEXP_SUBSTR.
This is the likely intended exam answer. Casting MessageText to nvarchar(4000) converts the large-value column into a bounded Unicode string before passing it to REGEXP_SUBSTR. The function can then search the supplied text using a regular expression pattern to extract the required ID. However, this approach can truncate text beyond 4,000 characters, so it should not be treated as a universal requirement.

🔴 Incorrect Options:

A. Apply STRING_ESCAPE(MessageText, 'json') before calling REGEXP_SUBSTR.
STRING_ESCAPE escapes special characters for JSON formatting. It does not convert the data type or improve regular expression compatibility. Applying it could also change the text being searched, making it unsuitable for this requirement.

C. Add a COLLATE Latin1_General_CS_AS clause to MessageText before calling REGEXP_SUBSTR.
The COLLATE clause controls collation-related comparison behavior, such as case sensitivity. T-SQL regular expression functions use their own matching flags rather than relying on column collation. Therefore, adding a collation clause does not solve the stated requirement.

D. Run TRY_CONVERT(varchar(max), MessageText) before calling REGEXP_SUBSTR.
TRY_CONVERT attempts to convert an expression into another data type and returns NULL if conversion fails. Converting to varchar(max) is unnecessary for extracting an ID because the input can be handled as Unicode text. It also does not address the supposed need for a bounded string.

🔧 Reference:
1. ⇒ REGEXP_SUBSTR (Transact-SQL)
Documents the function's syntax, supported input types, and LOB support up to 2 MB.

2. ⇒ RUse regular expression functions in Fabric Data Warehouse
Explains regex extraction, matching flags, and supported string inputs.
Question 19
You have an Azure subscription. The subscription contains an Azure SQL database named SalesDB and an Azure App Service app named sales-api. sales-api uses virtual network integration to a subnet named vnet-prod/subnet-app and reads from SalesDB You need to configure authentication and network access to meet the following requirements:

• Ensure that sales-api connects to SalesDB by using passwordless authentication.
• Ensure that all the database traffic remains within the subscription.

The solution must minimize administrative effort What should you configure? To answer, select the appropriate options in the answer area. NOTE: Each correct selection is worth one point.

Show answerHide answer

Explanation



Explanation:

This question tests how to configure secure, passwordless connections from an Azure App Service to Azure SQL Database while ensuring traffic never leaves the subscription's private network. The core requirements are eliminating stored credentials and restricting all database access to private endpoints only, which aligns with Azure best practices for zero-trust security and minimizing administrative overhead.

✔️ Correct Option:

Enable a managed identity and use Microsoft Entra authentication.
This option meets the passwordless requirement. By assigning a system-assigned managed identity to the App Service, the app can authenticate to Azure SQL Database using Microsoft Entra tokens without any passwords or connection string secrets . This eliminates credential rotation and storage, significantly reducing administrative effort.

Create a private endpoint and disable public network access.
This option ensures all database traffic remains within the subscription's virtual network. A private endpoint assigns a private IP address from the App Service's integrated subnet (vnet-prod/subnet-app) to the SQL server, routing traffic over the Azure backbone . Disabling public network access blocks all internet connections, guaranteeing that only traffic from the virtual network can reach the database .

❌ Incorrect Options:

Configure client certificate authentication for sales-api.
This approach still requires managing and rotating certificates, which increases administrative overhead. It also does not provide the seamless, secret-free authentication that managed identities offer for Azure-to-Azure connections.

Use a connection string with rotated SQL credentials weekly.
This introduces ongoing administrative burden and security risks. Managing rotating credentials requires automation and storage, contradicting the "passwordless" requirement and the goal of minimizing administrative effort.

Create a SQL login and store the SQL credentials in Azure Key Vault.
While more secure than hardcoding credentials, this still relies on password-based authentication. It requires Key Vault management, secret rotation, and access policies, adding complexity compared to a managed identity.

Allow Azure services and keep the public endpoint enabled.
This option violates the requirement to keep all database traffic within the subscription. The "Allow Azure services" rule permits connections from any Azure tenant, including other customers, and the public endpoint exposes the database to the internet .

Add IP firewall rules for the App Service outbound IP addresses.
This approach is unreliable because App Service outbound IPs can change, requiring constant firewall updates. It also uses the public endpoint, meaning traffic does not remain exclusively within the subscription's private network.

Configure a database-level firewall rule for support IP addresses.
This only restricts access for specific IPs but still uses the public endpoint, failing the requirement to keep all traffic private. It also does not address the passwordless authentication requirement.

🔧 Reference:
→ Tutorial: Use managed identity to connect an Azure web app to an Azure SQL database without secrets - Confirms that managed identity enables passwordless authentication from App Service to Azure SQL Database.

→ Implement network isolation - Confirms that private endpoints with public access disabled ensure all database traffic stays within the virtual network.
Question 20 Choose 1
You need to design a generative Al solution that uses a Microsoft SOL Server 2025 database named DB1 as a data source. The solution must generate responses that meet the following requirements:
• Ait' grounded In the latest transactional and reference data stored in D61
• Do NOT require retraining or fine-tuning the language model when the data changes
• Can include citations or references to the source data used in the response
Which scenario is the best use case for implementing a Retrieval Augmented Generation (RAG) pattern? More than one answer choice may achieve the goal. Select the BEST answer
Show answerHide answer

Correct answer: C answering user questions based on company-specific knowledge

Explanation

Explanation:

The question tests the use of Retrieval Augmented Generation (RAG) to provide accurate, up-to-date responses using external data sources. RAG retrieves relevant information from a database and provides it to the language model as context, allowing responses to reflect current data without retraining or fine-tuning the model.

🟢 Correct Option:

C. Answering user questions based on company-specific knowledge.
RAG is designed to answer questions using relevant information retrieved from external data sources, such as a SQL Server database. When a user asks a question, the system retrieves matching company-specific records and provides them as context to the language model. This allows the model to generate responses grounded in the latest available information. It also supports source references or citations, while database updates can be reflected without retraining the model.

🔴 Incorrect Options:

A. Summarizing free-form user input text.
Summarizing free-form text does not normally require retrieving information from an external knowledge source. A language model can summarize the supplied text directly. RAG is more useful when responses must be grounded in external or frequently updated information.

B. Training a custom language model on historical database data.
This scenario involves training or fine-tuning a language model using historical information. RAG does not require retraining the model whenever database records change. Instead, it retrieves updated information at query time and supplies it as context.

D. Generating marketing slogans based on user sentiment analysis.
Generating marketing slogans based on sentiment analysis is primarily a creative text-generation task. It does not require retrieving company-specific database records or providing citations to transactional data. A language model can generate slogans using the supplied sentiment information without RAG.

🔧 Reference:
1. ⇒ Intelligent applications and AI
Explains how database information can be retrieved and supplied to language models for grounded responses.

2. ⇒ Retrieval-augmented generation (RAG) in Azure AI Search
Explains how RAG retrieves external information to generate context-aware responses with source references.
Full mock exam

Sit the DP-800 exam before exam day

Full-length mocks with the same number of questions and the same time limit as the real DP-800 exam. Every attempt draws a new set of questions from the full bank, so you can keep going until you pass comfortably.

Get full DP-800 mock exam
  • 60questions per mock
  • 100 mintime limit
  • 87questions in the bank
  • Newmock on every attempt