Microsoft certification · Exam DP-800

DP-800 Mock Exam Page 2

Developing AI-Enabled Database Solutions

Free DP-800 questions on Topic 2, Misc. Questions Types, each with the answer and an explanation.

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

Topic 2, Misc. Questions Types questions

11–20 of 23 free
Question 11
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 12 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 13
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 14 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 15
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 16 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 17
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 18 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.
Question 19 Choose 2
You have an Azure SQL database named AdventureWorksDB that contains a table named dbo.Employee.
You have a C# Azure Functions app that uses an HTTP-triggered function with an Azure SQL input binding to query dbo.Employee.
You are adding a second function that will react to row changes in dbo.Employee and write structured logs.
You need to configure AdventureWorksDB and the app to meet the following requirements:
β€’ Changes to dbo.Employee must trigger the new function within five seconds.
β€’ Each invocation must processes no more than 100 changes.
Which two database configurations should you perform? Each correct answer presents part of the solution. NOTE: Each correct selection is worth one point.
Show answerHide answer

Correct answer: C, D Enable change tracking on the dbo. Employee table.Enable change tracking at the database level.

Explanation

Explanation:

This question tests the database prerequisites for an Azure SQL trigger in Azure Functions. The trigger detects INSERT, UPDATE, and DELETE changes by using SQL Server change tracking. Change tracking must be enabled first at the database level and then on the specific monitored table.

βœ”οΈ Correct Option:

βœ”οΈ C β€” Enable change tracking on the dbo.Employee table.
The Azure SQL trigger monitors changes to a specific table through SQL change tracking. Enabling change tracking on dbo.Employee allows the trigger to identify inserted, updated, and deleted rows and pass those changes to the function. This is mandatory for the new function to react to row changes in the table.

βœ”οΈ D β€” Enable change tracking at the database level.
Change tracking must be enabled for AdventureWorksDB before it can be enabled for dbo.Employee. The database-level setting maintains the change-tracking infrastructure and retention policy, while the table-level setting specifies the table monitored by the Azure SQL trigger. Both settings are required database configurations.

❌ Incorrect Options:

❌ A β€” Create an AFTER trigger on dbo.Employee for DML.
A traditional DML trigger runs inside the database when a change occurs, but it is not the mechanism used by the Azure Functions SQL trigger. The Azure SQL trigger specifically relies on SQL change tracking, not an AFTER INSERT, UPDATE, or DELETE trigger.

❌ B β€” Set Sql_Trigger_MaxBatchSize to 100.
This controls the maximum number of changes sent to the function in one trigger iteration, but it is an Azure Functions application/host configuration setting, not a database configuration. Also, 100 is already the default value, so it is not one of the required database changes.

❌ E β€” Set Sql_Trigger_PollingIntervalMs to 5000.
This setting controls the delay between polling cycles and is configured in the Azure Functions app, not in the SQL database. A value of 5,000 ms would mean up to a five-second delay between polls, but it is not a database configuration and is unnecessary because the default polling interval is already 1,000 ms.

❌ F β€” Enable change data capture (CDC) for dbo.Employee table changes.
Change Data Capture captures detailed row changes for consumption, but the Azure SQL trigger for Functions is documented as using SQL change tracking, not CDC. Enabling CDC does not satisfy the required change-tracking configuration for this trigger.

πŸ”§ Reference:
β†’ Azure SQL trigger for Functions β€” Microsoft Learn β€” Confirms that the trigger uses SQL change tracking and requires it at both database and table level.

β†’ Manipulate data in Azure SQL Database with Azure Functions β€” Microsoft Learn β€” Shows the required ALTER DATABASE ... SET CHANGE_TRACKING = ON and ALTER TABLE ... ENABLE CHANGE_TRACKING steps.
Question 20
You have an Azure SQL database that contains the following tables and columns.

Embeddings in the NotesEnbeddings and DescriptionEabeddings tables have been generated from values in the Description and notes columns of the Articles table by using different chunk sizes. You need to perform approximate nearest neighbor (ANN) queries across both embedding tables. The solution must minimize the impact of using different chunk sizes. What should you use? 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 evaluates the implementation of approximate nearest neighbor (ANN) queries across multiple embedding tables that use different chunking strategies. The goal is to minimize the impact of varying chunk sizes by selecting the appropriate vector search function and distance metric that align with how embeddings are typically generated and compared.

βœ”οΈ Correct Option:

VECTOR_SEARCH:
This function is designed specifically for approximate nearest neighbor searches using vector indexes. It allows you to query a vector column and retrieve the most similar vectors efficiently, which is essential when performing ANN queries across tables like NotesEmbeddings and DescriptionEmbeddings . Using VECTOR_SEARCH ensures the query leverages the vector index rather than performing a full scan.

cosine distance:
Cosine distance measures the angle between vectors, ignoring their magnitude. This is particularly effective when comparing embeddings generated from different chunk sizes, as it focuses on the semantic direction of the vectors rather than their length. Most embedding models are optimized for cosine similarity, making cosine distance the standard metric for such comparisons .

❌ Incorrect Options:

VECTOR_DISTANCE:
This function calculates the exact distance between vectors and is used for precise nearest neighbor searches. It requires scanning every row in the table, which is inefficient for large datasets and does not leverage the ANN index that VECTOR_SEARCH utilizes .

Vector_NORM:
This is not a valid vector search function in Azure SQL Database. It likely refers to a mathematical norm operation, which is unrelated to retrieving nearest neighbors from embedding tables.

dot product:
While dot product can be used as a similarity measure, it is sensitive to vector magnitude. Different chunk sizes can produce embeddings of varying magnitudes, making dot product less reliable for comparing them compared to cosine distance .

Euclidean distance:
This metric considers both direction and magnitude. Because different chunk sizes may result in embeddings with different magnitudes, Euclidean distance can be skewed by these size differences. Cosine distance is generally preferred for comparing embeddings from varied chunking strategies .

πŸ”§ Reference:
β†’ VECTOR_SEARCH (Transact-SQL) - Confirms VECTOR_SEARCH is used for approximate nearest neighbor searches with vector indexes.

β†’ Prepare SQL for vector search - Explains that cosine distance is commonly used for embedding comparisons as it focuses on direction rather than magnitude.
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