πŸ”’ Guided

Pre-launch preview. Authorised access only.

Incorrect code

Guided by A Guide to Cloud
Explore AB-900 AI-901
Guided DP-800 Domain 1
Domain 1 β€” Module 4 of 10 40%
4 of 28 overall

DP-800 Study Guide

Domain 1: Design and Develop Database Solutions

  • Table Design: Columns, Types, and Indexes Free
  • Constraints: Protecting Your Data Free
  • Specialised Tables and Graph Queries Free
  • JSON in SQL: Store, Query, and Index
  • Programmability: Views, Functions, Procedures, and Triggers
  • Advanced T-SQL: CTEs, Windows, and Correlated Queries
  • Pattern Power: Regular Expressions in T-SQL
  • Fuzzy String Matching: Finding Similar Text
  • AI-Assisted SQL with GitHub Copilot Free
  • MCP: Connecting AI to Your Database

Domain 2: Secure, Optimize, and Deploy Database Solutions

  • Encryption: Always Encrypted and Column-Level
  • Dynamic Data Masking and Row-Level Security
  • Permissions, Auditing, and Passwordless Access
  • Transaction Isolation and Concurrency
  • Query Performance: Plans, DMVs, and Query Store
  • SQL Database Projects: Build and Validate
  • CI/CD Pipelines for SQL Databases
  • Data API Builder: REST and GraphQL from SQL
  • Securing AI and API Endpoints
  • Change Detection: CES, CDC, and Change Tracking
  • Azure Integration and Monitoring

Domain 3: Implement AI Capabilities in Database Solutions

  • External AI Models: Choose, Create, Manage
  • Embeddings: Design, Chunk, and Generate
  • Choose Your Search Strategy
  • Vector Data: Types, Indexes, and Storage
  • Vector Search: Distance, ANN, and ENN
  • Hybrid Search and Reciprocal Rank Fusion
  • RAG with SQL: Prompt, Process, Respond

DP-800 Study Guide

Domain 1: Design and Develop Database Solutions

  • Table Design: Columns, Types, and Indexes Free
  • Constraints: Protecting Your Data Free
  • Specialised Tables and Graph Queries Free
  • JSON in SQL: Store, Query, and Index
  • Programmability: Views, Functions, Procedures, and Triggers
  • Advanced T-SQL: CTEs, Windows, and Correlated Queries
  • Pattern Power: Regular Expressions in T-SQL
  • Fuzzy String Matching: Finding Similar Text
  • AI-Assisted SQL with GitHub Copilot Free
  • MCP: Connecting AI to Your Database

Domain 2: Secure, Optimize, and Deploy Database Solutions

  • Encryption: Always Encrypted and Column-Level
  • Dynamic Data Masking and Row-Level Security
  • Permissions, Auditing, and Passwordless Access
  • Transaction Isolation and Concurrency
  • Query Performance: Plans, DMVs, and Query Store
  • SQL Database Projects: Build and Validate
  • CI/CD Pipelines for SQL Databases
  • Data API Builder: REST and GraphQL from SQL
  • Securing AI and API Endpoints
  • Change Detection: CES, CDC, and Change Tracking
  • Azure Integration and Monitoring

Domain 3: Implement AI Capabilities in Database Solutions

  • External AI Models: Choose, Create, Manage
  • Embeddings: Design, Chunk, and Generate
  • Choose Your Search Strategy
  • Vector Data: Types, Indexes, and Storage
  • Vector Search: Distance, ANN, and ENN
  • Hybrid Search and Reciprocal Rank Fusion
  • RAG with SQL: Prompt, Process, Respond
Domain 1: Design and Develop Database Solutions Premium ⏱ ~13 min read

JSON in SQL: Store, Query, and Index

Store semi-structured data as native JSON, query it with built-in functions, and index JSON properties for fast lookups β€” bridging the gap between relational and document models.

Why JSON in a relational database?

β˜• Simple explanation

Think of a restaurant that serves both set menus and custom orders.

Your regular tables are like set menus β€” every dish (column) is predefined. But sometimes customers want something custom β€” extra toppings, special requests, dietary notes. Instead of adding a new column for every possible request, you store the custom details as a flexible note (JSON) alongside the set menu items.

JSON in SQL gives you the best of both worlds: strict relational structure for your core data, and flexible document storage for data that varies between rows β€” product attributes, user preferences, API responses, or configuration settings.

SQL Server 2025 introduces a native JSON data type that stores JSON in an optimised binary format, replacing the previous approach of storing JSON as NVARCHAR. Combined with JSON functions (JSON_VALUE, OPENJSON, JSON_OBJECT, JSON_ARRAY, JSON_ARRAYAGG, JSON_CONTAINS), you can store, query, and index semi-structured data directly within your relational schema.

The DP-800 exam tests your ability to choose when JSON columns are appropriate (vs additional relational tables), design JSON indexes for query performance, and write queries that extract, construct, and search JSON data.

The JSON data type (SQL Server 2025)

SQL Server 2025 adds a native JSON data type that stores JSON in binary format β€” smaller and faster than NVARCHAR.

CREATE TABLE Products (
    ProductId INT NOT NULL PRIMARY KEY,
    Name NVARCHAR(200) NOT NULL,
    Price DECIMAL(10,2) NOT NULL,
    Attributes JSON NULL    -- Flexible properties that vary by product
);

INSERT INTO Products (ProductId, Name, Price, Attributes)
VALUES (1, 'Wireless Mouse', 29.99,
    '{"color": "black", "dpi": 1600, "wireless": true, "battery": "AA"}');

Reading JSON: JSON_VALUE and OPENJSON

JSON_VALUE β€” extract a single scalar value

-- Get the color of product 1
SELECT Name, JSON_VALUE(Attributes, '$.color') AS Color
FROM Products
WHERE ProductId = 1;
-- Returns: Wireless Mouse, black

The $ represents the root. Navigate nested objects with dots: $.address.city.

OPENJSON β€” shred JSON into rows and columns

-- Expand a JSON array into rows
DECLARE @json NVARCHAR(MAX) = '[
    {"name": "Alice", "role": "Developer"},
    {"name": "Bob", "role": "DBA"},
    {"name": "Carol", "role": "Architect"}
]';

SELECT name, role
FROM OPENJSON(@json)
WITH (
    name NVARCHAR(100) '$.name',
    role NVARCHAR(100) '$.role'
);

OPENJSON is essential for converting JSON arrays (from API responses, for example) into relational rows you can join, filter, and aggregate.

Building JSON: JSON_OBJECT, JSON_ARRAY, JSON_ARRAYAGG

These functions construct JSON from relational data β€” the reverse of OPENJSON.

-- JSON_OBJECT: build a JSON object from key-value pairs
SELECT JSON_OBJECT('id': ProductId, 'name': Name, 'price': Price) AS ProductJson
FROM Products;
-- Returns: {"id":1,"name":"Wireless Mouse","price":29.99}

-- JSON_ARRAY: build a JSON array from values
SELECT JSON_ARRAY(1, 'hello', 3.14, NULL ABSENT ON NULL) AS ArrayResult;
-- Returns: [1,"hello",3.14]

-- JSON_ARRAYAGG: aggregate rows into a JSON array
SELECT JSON_ARRAYAGG(JSON_OBJECT('name': Name, 'price': Price)) AS AllProducts
FROM Products;
-- Returns: [{"name":"Wireless Mouse","price":29.99}, ...]
πŸ’‘ Exam tip: JSON_ARRAYAGG is an aggregate function

JSON_ARRAYAGG works like STRING_AGG or SUM β€” it collapses multiple rows into a single JSON array value. You can use it with GROUP BY to create nested JSON structures from relational data. This is commonly needed when preparing data for AI model input (Domain 3 β€” converting relational data to JSON for language model processing).

Searching JSON: JSON_CONTAINS

JSON_CONTAINS checks whether a JSON document contains a specified value or fragment:

-- Find all products where Attributes contains "wireless": true
SELECT Name, Price
FROM Products
WHERE JSON_CONTAINS(Attributes, 'true', '$.wireless') = 1;

Indexing JSON columns

JSON columns cannot be indexed directly. Instead, create computed columns that extract specific JSON values, then index those computed columns:

-- Add a computed column for the color property
ALTER TABLE Products
ADD Color AS JSON_VALUE(Attributes, '$.color');

-- Index it
CREATE NONCLUSTERED INDEX IX_Products_Color
ON Products (Color);

-- Now this query uses the index
SELECT Name, Price FROM Products WHERE Color = 'black';

For the native JSON type in SQL Server 2025, you can also use JSON indexes directly on JSON path expressions.

Native JSON type vs NVARCHAR β€” prefer native when available
ApproachJSON in NVARCHARNative JSON Type (2025)
Storage formatText (UTF-16)Optimised binary
Storage sizeLarger (text overhead)Smaller (compressed binary)
ValidationISJSON() check constraintAutomatic β€” rejects invalid JSON
PerformanceParse on every readPre-parsed, faster queries
IndexingComputed columns + indexesJSON indexes on path expressions
CompatibilityAll SQL Server versionsSQL Server 2025+ and Azure SQL
πŸ’‘ Scenario: Leo's product catalog at SearchWave

Leo Torres at SearchWave is building a product catalog where every product category has different attributes. Electronics have β€œbattery life” and β€œweight.” Clothing has β€œsize” and β€œmaterial.” Food has β€œallergens” and β€œexpiry.”

Instead of creating columns for every possible attribute (most would be NULL), Leo stores the variable attributes as JSON:

CREATE TABLE Catalog (
    ProductId INT NOT NULL PRIMARY KEY,
    CategoryId INT NOT NULL,
    Name NVARCHAR(200) NOT NULL,
    BasePrice DECIMAL(10,2) NOT NULL,
    Specs JSON NULL  -- Category-specific attributes
);

He creates computed columns and indexes for the most-queried paths (like $.brand and $.rating), and uses OPENJSON for ad-hoc exploration of less common attributes.

This pattern β€” relational for core data, JSON for variable attributes β€” is a common exam scenario.

Question

What is the difference between JSON_VALUE and OPENJSON?

Click or press Enter to reveal answer

Answer

JSON_VALUE extracts a single scalar value from a JSON document (returns one value). OPENJSON shreds a JSON array or object into rows and columns (returns a table). Use JSON_VALUE for single lookups, OPENJSON for converting JSON arrays into relational rows.

Click to flip back

Question

How do you index a JSON property for fast lookups?

Click or press Enter to reveal answer

Answer

Create a computed column that extracts the JSON value using JSON_VALUE, then create a nonclustered index on that computed column. In SQL Server 2025 with the native JSON type, you can also create JSON indexes directly on path expressions.

Click to flip back

Question

What does JSON_ARRAYAGG do?

Click or press Enter to reveal answer

Answer

JSON_ARRAYAGG is an aggregate function that collapses multiple rows into a single JSON array. Like SUM or STRING_AGG, it works with GROUP BY. It is essential for converting relational query results into JSON format for API responses or AI model input.

Click to flip back

Knowledge Check

Priya at Vault Bank receives customer KYC (Know Your Customer) data from an external API as JSON arrays. She needs to insert this data into a relational Customers table. Which function should she use to convert the JSON array into rows?

Knowledge Check

Leo at SearchWave needs to generate a JSON API response that includes each product with its reviews nested as a JSON array. Which approach produces the correct nested JSON?

🎬 Video coming soon

Next up: Programmability: Views, Functions, Procedures, and Triggers β€” create reusable database objects that encapsulate logic.

← Previous

Specialised Tables and Graph Queries

Next β†’

Programmability: Views, Functions, Procedures, and Triggers

Guided

I learn, I simplify, I share.

A Guide to Cloud YouTube Feedback

© 2026 Sutheesh. All rights reserved.

Guided is an independent study resource and is not affiliated with, endorsed by, or officially connected to Microsoft. Microsoft, Azure, and related trademarks are property of Microsoft Corporation. Always verify information against Microsoft Learn.