DP-800 SQL AI Developer Study Guide & Exam Questions

Free practice exam

DP-800 Practice Exam: 21 Free Exam Questions

Test yourself on 21 exam questions picked from every domain of the study guide. You get your score per domain at the end, with every answer explained.

  • 21 exam questions
  • 3 domains
  • About 25 minutes
  • No account needed

One question at a time, like the real exam: results and explanations come after the last question. Nothing you answer is saved.

What the exam covers

Exam domainExam questions
1. Part 1: Database Objects, Advanced T-SQL and AI-Assisted Development7
2. Part 2: Security, Performance Tuning and CI/CD Deployment7
3. Part 3: AI in SQL: Embeddings, Vector Search and RAG7

The 21 exam questions

Read them through, or start the exam to answer them and see how you score.

A Microsoft Fabric SQL database holds a table called WebSite.Logs used for application telemetry. Its log column, defined as nvarchar(max), holds JSON documents. A daily report filters rows on the $.severity property inside that JSON and returns the LogId, LogDateTime and log columns, but it often scans the whole table. The table must be changed so filtering on that JSON property can seek efficiently and the columns returned by the report can be satisfied without returning to the base table.

ALTER TABLE WebSite.Logs
ADD severity [Target 1];
GO
CREATE INDEX ix_severity
ON WebSite.Logs(severity)
[Target 2];
GO
1. Target 1, which defines the new severity column, should be ____, while Target 2, which finishes the index definition, should be ____.

Complete the Transact-SQL code.

  • AS JSON_QUERY([log], '$.severity')
  • AS JSON_VALUE([log], '$.severity') PERSISTED
  • INCLUDE (log)
  • INCLUDE (LogId, LogDateTime, [log])

An Azure SQL database holds dbo.SupportTickets with a JSON Payload column and a datetime CreatedAt column. You must build a seven-day report with one row for every customer on every day, keeping the earliest ticket and exposing the customer identifier stored in Payload.

2. WITH TicketRanks AS ( SELECT t.TicketId, CAST(t.CreatedAt AS date) AS TicketDate, ____(t.Payload, '$.customer.id') AS CustomerId, t.CreatedAt, ____() OVER ( PARTITION BY CAST(t.CreatedAt AS date), JSON_VALUE(t.Payload, '$.customer.id') ORDER BY t.CreatedAt ASC ) AS rn FROM dbo.SupportTickets AS t WHERE t.CreatedAt >= DATEADD(day, -7, SYSUTCDATETIME()) ) SELECT TicketDate, CustomerId, TicketId, CreatedAt FROM TicketRanks WHERE rn = ____ ORDER BY TicketDate, CustomerId;

Finish the statement by picking the proper expression for every gap.

  • 1
  • 7
  • DATEDIFF(day, -7, SYSUTCDATETIME())
  • DENSE_RANK
  • JSON_VALUE
  • OPENJSON
  • ROW_NUMBER

Developers must fetch every transaction for one patient inside a date window together with a running total. In dbo.Transactions the CustomerId column denotes the patient, and the result must be joinable to other tables in later queries.

3. Complete the object so it accepts parameters, stays joinable and computes the total in date order: CREATE ____ dbo.CustomerTransactionsBetweenDates ( @CustomerId INT, @StartDate DATETIME2, @EndDate DATETIME2 ) RETURNS TABLE AS RETURN ( SELECT t.TransactionId, t.CustomerId, t.TransactionDate, t.Amount, SUM(t.Amount) OVER ( ____ ____ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) AS RunningTotal FROM dbo.Transactions AS t WHERE t.CustomerId = @CustomerId AND t.TransactionDate >= @StartDate AND t.TransactionDate <= @EndDate );

Running-total routine

  • FUNCTION
  • GROUP BY t.CustomerId
  • GROUP BY t.TransactionDate
  • HAVING DATEDIFF(DAY, t.TransactionDate, GETDATE()) = 1
  • HAVING SUM (t.Amount) > 0
  • ORDER BY t.TransactionDate, t.TransactionId
  • ORDER BY t.TransactionId, t.CustomerId
  • PARTITION BY t.CustomerId
  • PARTITION BY t.TransactionDate
  • PROCEDURE
  • VIEW

An Azure SQL database exposes graph data for people and their connections.

  • A node table called dbo.Person holds people.
  • An edge table called dbo.Knows models directed familiarity.
  • Each person row carries PersonId of type int and DisplayName of type nvarchar(100).
  • The search must start from the person supplied in @StartPersonId.
4. Which statement traverses exactly two directed Knows links in one MATCH clause to fetch the two-step contacts?
  • SELECT p2.PersonId, @StartPersonId FROM dbo.Person AS p1, dbo.Knows AS k1, dbo.Person AS p2, dbo.Knows AS k2, dbo.Person AS p3 WHERE p1.DisplayName = p2.DisplayName AND MATCH(p1-(k1)->p2-(k2)->p3);
  • SELECT p3.PersonId, p3.DisplayName FROM dbo.Person AS p1 JOIN dbo.Knows AS k1 ON 1 = 1 JOIN dbo.Person AS p2 ON 1 = 1 JOIN dbo.Knows AS k2 ON 1 = 1 JOIN dbo.Person AS p3 ON 1 = 1 WHERE p1.PersonId = @StartPersonId AND MATCH(p3<-(k2)-p2<-(k1)-p1);
  • SELECT p3.PersonId, p3.DisplayName FROM dbo.Person AS p1, dbo.Knows AS k1, dbo.Person AS p2, dbo.Knows AS k2, dbo.Person AS p3 WHERE p1.PersonId = @StartPersonId AND MATCH(p1-(k1)->p2) AND MATCH(p2-(k2)->p3);
  • SELECT p3.PersonId, p3.DisplayName FROM dbo.Person AS p1, dbo.Knows AS k1, dbo.Person AS p2, dbo.Knows AS k2, dbo.Person AS p3 WHERE p1.PersonId = @StartPersonId AND MATCH(p1-(k1)->p2-(k2)->p3);

Contoso stores user remarks in CustomerFeedback, which holds an identifier plus a JSON payload column. The payload column is already covered by a full-text index and each document carries the remark, a category and nested metadata.

{
  "text": "The battery drains too fast when driving uphill.",
  "category": "Battery",
  "metadata": {
    "appVersion": "5.2.1",
    "device": "Android",
    "language": "en-GB"
  }
}

Queries against that payload must satisfy four goals for the development team.

  • Pull the free-form remark stored in the text property out of the JSON.
  • Keep only rows whose indexed text mentions a supplied keyword.
  • Score how closely each remark resembles a known problem description with a fuzzy function.
  • Present the closest resemblances first.
5. Complete the statement so all four FeedbackJson goals are met: SELECT f.FeedbackId, ____, EDIT_DISTANCE_SIMILARITY( JSON_VALUE(f.FeedbackJson, '$.text'), @KnownIssueDescription ) AS SimilarityScore FROM dbo.CustomerFeedback f WHERE ____ ORDER BY ____ DESC;

Feedback search query

  • CONTAINS(FeedbackJson, @Keyword)
  • EDIT_DISTANCE(JSON_VALUE(f.FeedbackJson, '$.details.comment'), @Keyword) < 3
  • EDIT_DISTANCE(JSON_VALUE(f.FeedbackJson, '$.text'), @Keyword) < 3
  • JSON_QUERY(f.FeedbackJson, '$.text', @KnownIssueDescription) AS FeedbackText
  • JSON_VALUE(f.FeedbackJson, '$.text') AS FeedbackText
  • SimilarityScore

A SQL database in Microsoft Fabric keeps customer records as JSON in a column called Payload. Each document carries a date and a customer email address.

{
  "date": "2020-01-25",
  "customer_email": "user@contoso.com"
}
6. Analysis shows some addresses use plus-addressing, for example user1+news@contoso.com, which must be reduced to user1@contoso.com. Which Transact-SQL expression returns the email with any subaddress tag stripped out?
  • REGEXP_REPLACE(JSON_VALUE(Payload, '$.customer_email'), '\+.*$', '')
  • REGEXP_SUBSTR(JSON_VALUE(Payload, '$.customer_email'), '^[^+]+@.*$=')
  • REGEXP_REPLACE(JSON_VALUE(Payload, '$.customer_email'), '\+.*@', '@')
  • REGEXP_REPLACE(JSON_VALUE(Payload, '$.customer_email'), '\+.*', '')

A Microsoft SQL Server 2025 database includes dbo.CustomerMessages with MessageID of type int and MessageRaw of type nvarchar(max). MessageRaw may hold a telephone number in varied layouts or no number at all, with at most one number per message.

  • The result must include MessageID, RawNumber, DigitsOnly and PhoneStatus.
  • RawNumber holds the first substring matching a phone pattern, or NULL when absent.
  • DigitsOnly strips every non-digit from RawNumber, or yields NULL.
  • PhoneStatus shows Valid when MessageRaw contains a number, otherwise Missing.
7. Complete the query: SELECT MessageID, ____ MessageRaw, '\d{3}[)\-\s]*\d{3}[\-\s]*\d{4}' ) AS RawNumber, ____ MessageRaw, '\d{3}[)\-\s]*\d{3}[\-\s]*\d{4}' ), '\D', '') AS DigitsOnly, CASE WHEN ____ MessageRaw, '\d{3}[)\-\s]*\d{3}[\-\s]*\d{4}') = 1 THEN 'Valid' ELSE 'Missing' END AS PhoneStatus FROM dbo.CustomerMessages;

Finish the single SELECT statement by placing the correct function in each gap.

  • REGEXP_COUNT(
  • REGEXP_INSTR(
  • REGEXP_REPLACE( REGEXP_SUBSTR(
  • REGEXP_SUBSTR(
  • STRING_SIMILARITY(

Database DB1 contains an Orders table with one row per sales order, including the name of the user who submitted each order. Row-level security must limit every user to seeing solely the sales orders they submitted.

8. The solution must create ____ and govern which rows are visible by using ____.

Row-level security building blocks

  • A masking rule
  • A materialized view in DB1
  • A security policy in the Orders table
  • A table-valued function
  • Database scoped credentials in DB1
  • The CONTAINS predicate

A Customer table pairs a per-customer NationalIDNumber with free-form InvestigationNotes.

  • NationalIDNumber is distinct for every customer.
  • InvestigationNotes carries unrestricted narrative.

A routine fetches single rows by NationalIDNumber and returns InvestigationNotes without sifting on that narrative. Secure enclaves are disabled. Both columns must carry Always Encrypted at the strongest workable strength.

9. Which Always Encrypted flavor fits each column?
  • deterministic for NationalIDNumber and randomized for InvestigationNotes
  • deterministic for NationalIDNumber and deterministic for InvestigationNotes
  • randomized for NationalIDNumber and randomized for InvestigationNotes
  • randomized for NationalIDNumber and deterministic for InvestigationNotes

An order-processing OLTP workload runs on an Azure SQL database. You must assemble Transact-SQL that exposes the chain of waiting sessions, listing only sessions that are waiting on another session or are causing other sessions to wait.

WITH cteBL (session_id, blocking_these) AS
(
    SELECT
        s.session_id,
        blocking_these = x.blocking_these
    FROM sys.dm_exec_sessions AS s
    CROSS APPLY
    (
        SELECT
            ISNULL(CONVERT(varchar(6), er.session_id), '') + ', '
        [Target 1] AS er
        WHERE er.blocking_session_id = ISNULL(s.session_id, 0)
          AND er.blocking_session_id <> 0
        FOR XML PATH('')
    ) AS x(blocking_these)
)
SELECT
    s.session_id,
    blocked_by = r.blocking_session_id,
    bl.blocking_these,
    batch_text = t.text,
    input_buffer = ib.event_info
FROM sys.dm_exec_sessions AS s
[Target 2] AS r ON r.session_id = s.session_id
INNER JOIN cteBL AS bl ON s.session_id = bl.session_id
[Target 3] AS t
[Target 4] AS ib
WHERE bl.blocking_these IS NOT NULL
   OR r.blocking_session_id > 0
ORDER BY LEN(bl.blocking_these) DESC, r.blocking_session_id DESC, r.session_id;
10. The inner source that finds sessions halted by each session is ____. The join that preserves idle head blockers is ____. The apply that fetches batch text is ____. The apply that fetches the latest input buffer is ____.

Finish the blocking-chain script

  • CROSS APPLY sys.dm_exec_sql_text (r.sql_handle)
  • FROM sys.dm_exec_requests
  • FROM sys.dm_tran_locks
  • INNER JOIN sys.dm_tran_locks
  • LEFT OUTER JOIN sys.dm_exec_requests
  • OUTER APPLY sys.dm_exec_input_buffer(r.session_id, 0)
  • OUTER APPLY sys.dm_exec_input_buffer(s.session_id, NULL)
  • OUTER APPLY sys.dm_exec_sql_text (r.sql_handle)

SQL Server on an Azure virtual machine hosts a database named DB1. An application queries DB1 to produce a sales report, and you must inspect the parameter values used the most recent time that reporting query ran.

11. Which two actions together let you see those values?
  • Turn on Last_Query_Plan_Stats in the master database
  • Turn on Lightweight_Query_Profiling in DB1
  • Turn on Last_Query_Plan_Stats in DB1
  • Turn on Lightweight_Query_Profiling in the master database
  • Turn on PARAMETER_SNIFFING in DB1

An order-taking OLTP system on Azure SQL Database suffered a ten-minute spell in which changes to Sales.Orders kept timing out. Checks during the spell revealed the following, and the timeouts ended once session 72 was ended manually.

  • Session 72 was sleeping with open_transaction_count = 1.
  • Several other sessions recorded blocking_session_id = 72 in sys.dm_exec_requests.
  • sys.dm_exec_input_buffer(72, NULL) showed only BEGIN TRANSACTION UPDATE Sales.Orders.
  • Intermittent waits on Sales.Orders persisted until session 72 was terminated.
12. Which circumstance could explain this wait chain?
  • A prolonged SELECT query is obstructing write operations.
  • Session 72 became entangled in a deadlock.
  • An explicit transaction was begun and never committed or rolled back.
  • Locks were escalated to a coarser granularity.

An Azure SQL database called AdventureWorksDB holds a table dbo.Employee. A C# Azure Functions app with an HTTP-triggered routine queries that table through an Azure SQL input binding. You are adding another routine that fires on row modifications and writes structured logs.

  • The new routine must fire within five seconds of a change to dbo.Employee.
  • Each run must handle at most 100 changed rows.
13. Which two database configurations are required? Each correct choice is one part of the answer.
  • Add an AFTER trigger on dbo.Employee for Data Manipulation Language (DML) operations.
  • Set Sql_Trigger_MaxBatchSize to 100.
  • Enable change tracking on the dbo.Employee table.
  • Enable change tracking at the database level.
  • Set Sql_Trigger_PollingIntervalMs to 5000.
  • Enable change data capture (CDC) for dbo.Employee table changes.

Database SQLDb1 contains Table1. A web app named webapp1 will export rows from Table1 that have changed. The design must keep both processor time and storage consumption as low as possible.

14. The actions to carry out in order are: as step 1, ____; as step 2, ____; and as step 3, ____.

Lightweight change detection sequence

  • Connect to SQLDb1 and run the following Transact-SQL statement: ALTER DATABASE SQLDb1 SET CHANGE_TRACKING = ON
  • Connect to SQLDb1 and run the following Transact-SQL statement: ALTER TABLE dbo.Table1 ENABLE CHANGE_TRACKING
  • Connect to SQLDb1 and run the following Transact-SQL statement: EXEC sys.sp_cdc_enable_db
  • Connect to SQLDb1 and run the following Transact-SQL statement: EXEC sys.sp_cdc_enable_table
  • From webapp1, connect to SQLDb1, obtain the initial dataset, and run the CHANGE_TRACKING_CURRENT_VERSION() function.
  • From webapp1, connect to SQLDb1, obtain the initial dataset, and run the CHANGETABLE() function.

Each medical procedure is kept as one wide row plus a single vector, so a similarity match returns whole documents and sends their full text to the model.

CREATE TABLE dbo.ProcedureDocuments
(
    DocumentId INT IDENTITY PRIMARY KEY,
    SourceId NVARCHAR(200) NULL,
    Content NVARCHAR(MAX) NOT NULL,
    Embedding VECTOR(1536) NOT NULL,
    CreatedAt DATETIME2 NOT NULL DEFAULT SYSUTCDATETIME()
);

Consuming those results through retrieval-augmented generation feels slow and consumes many tokens per lookup.

15. What should you introduce to speed retrieval and lower tokens per lookup?
  • chunking
  • embeddings
  • a small language model (SLM)
  • JSON content

A shop catalogue lives in SalesDB on SQL Server 2025 in a table named products.

  • product_id (int)
  • product_name (nvarchar(200))
  • description (nvarchar(max))
  • category (nvarchar(50))
  • brand (nvarchar(50))
  • price (decimal)
  • sku (nvarchar(40))

write-ups refresh each day through an ingestion flow, while price may move several times a day. Shoppers should ask in everyday wording and still narrow by brand and price. The design adds a VECTOR(1536) column searched with VECTOR_SEARCH(... METRIC = 'cosine' ...).

16. Merging product_name, category and description into the embedding input meets the shopping need.
  • True
  • False
17. Price wording must be included in the text that is embedded.
  • True
  • False
18. The stored elements will use float32 as their base type.
  • True
  • False

A SQL database in Microsoft Fabric named SalesDB contains dbo.Products. You must add a vector index on the proper column and query it with a provided natural-language query vector, returning the closest matches first.

19. CREATE VECTOR INDEX idx_products_embedding ON dbo.Products ( ____ ) WITH (METRIC = 'cosine', TYPE = 'DiskANN'); DECLARE @query_vector VECTOR(1536) = @SuppliedVector; SELECT TOP (10) WITH APPROXIMATE t.product_id, t.product_name, s.distance FROM ____ ( TABLE = dbo.Products AS t, COLUMN = embedding, SIMILAR_TO = @query_vector, METRIC = 'cosine' ) AS s ____

Choose the correct fragment for each gap.

  • distance
  • embedding
  • GROUP BY s.distance
  • ORDER BY s.distance
  • PARTITION BY s.distance
  • product_name
  • VECTOR_DISTANCE
  • VECTOR_NORMALIZE
  • VECTOR_SEARCH

An Azure SQL database keeps a stores table whose description column carries a full-text index and whose embedding column carries a cosine vector index.

  • Use index-backed nearest-neighbor lookup on embedding for the meaning-based half.
  • Use full-text lookup on description for literal terms and phrases.
  • Surface the finest 20 rows through a blended score weighted 60 percent vector distance and 40 percent full-text rank.
20. The meaning-based piece should use ____. The word-based piece should use ____. The blended ordering should use ____.

Assemble the hybrid retrieval query

  • CONTAINSTABLE on description and return ranked matches
  • FREETEXTTABLE on description for keyword scoring
  • JSON_VALUE extraction from description for keyword scoring
  • order by (distance * 0.6) + ((1.0 - RANK/1000.0) * 0.4)
  • order by (distance * 0.6) + (RANK * 0.4)
  • order by (distance + RANK), and then apply TOP 20
  • VECTOR_DISTANCE and order by distance ascending
  • VECTOR_SEARCH with METRIC cosine and SELECT TOP (N) WITH APPROXIMATE
  • VECTORPROPERTY to calculate the similarity between two vectors

An Azure SQL database named SalesDB stores Sales.Orders and Sales.OrderLines. A Retrieval Augmented Generation service fetches order details and hands them to a large language model as JSON. You must emit one JSON array in which every order object carries its header fields plus a lines array of its items.

[
  {
    "orderHeaderId": 102348,
    "orderNumber": "SO-2026-000912",
    "orderDateUtc": "2026-01-28T14:22:09Z",
    "customerId": 77821,
    "currencyCode": "EUR",
    "orderTotal": 149.97,
    "lines": [
      {
        "lineNumber": 1,
        "productId": 5012,
        "sku": "CBL-USB-C-1M",
        "quantity": 2,
        "unitPrice": 19.99,
        "lineTotal": 39.98
      },
      {
        "lineNumber": 2,
        "productId": 8841,
        "sku": "HUB-USB-C-7P",
        "quantity": 1,
        "unitPrice": 109.99,
        "lineTotal": 109.99
      }
    ]
  }
]
21. Which Transact-SQL commands produce the needed shape from the relational tables? Serialize the order-level JSON: ____ Generate a nested lines array: ____ Extract a single scalar value from the JSON text: ____

Pick the right command for each purpose.

  • FOR JSON PATH
  • JSON_MODIFY
  • JSON_QUERY
  • JSON_VALUE
  • OPENJSON