-- Simplified concept: primary replica and secondary replicas
-- stay synchronized, with automatic failover configured
CREATE AVAILABILITY GROUP MyAG
FOR DATABASE MyDatabase
REPLICA ON 'ServerA' WITH (...), 'ServerB' WITH (...);
Topics
43
Aggregate Functions & GROUP BY
Always On Availability Groups
Backup & Recovery
Change Data Capture (CDC)
Columnstore Indexes
Common Table Expressions (CTEs)
Constraints (Primary Key, Foreign Key, Check & Unique)
Cursors
Data Types & Schema Design
Deadlocks
Dynamic Data Masking
Dynamic SQL
Error Handling with TRY CATCH
Full Text Search
Hash Indexes & Hash Join Operations
Indexes
In-Memory OLTP (Memory-Optimized Tables)
Isolation & Locking
Joins
JSON Support in SQL Server
Linked Servers
Merge Statement (Upsert)
Normalization
Partitioning
Pivoting & Unpivoting Data
Query Optimization & Plans
Query Store
Replication
SQL Server Agent & Job Scheduling
SQL Server Architecture & Editions
SQL Server Profiler & Extended Events
SQL Server Security & Permissions
Stored Procedures & Functions
Subqueries
Temporary Tables & Table Variables
Transactions & ACID
Transparent Data Encryption
Triggers
T-SQL Fundamentals & Syntax
User Defined Functions
Views
Window Functions
XML Data Type & Querying
Always On Availability Groups
7 questions found
An Always On Availability Group is a high availability feature that keeps a copy of one or more databases synchronized across multiple SQL Server instances, so if the main server fails, another server already holding an up to date copy can take over quickly, minimizing downtime for your applications.
Real-world example
An online banking system uses an Always On Availability Group so that if its primary database server suddenly goes offline, a secondary server automatically takes over within seconds, keeping the banking application available to customers.
Backup & Recovery;Replication
What is the difference between the primary replica and secondary replicas in an Always On Availability Group?
BeginnerThe primary replica is the active database that handles all the read and write operations from your applications, while secondary replicas hold a continuously updated copy of that data and can optionally be used for read only reporting queries, backups, or as a standby ready to take over if the primary fails.
-- Read only routing lets reporting queries run against a secondary replica
-- instead of adding extra load to the primary
Real-world example
A company offloads its heavy reporting queries to a secondary replica, keeping the primary replica free to handle the application's regular transactional workload without slowing down.
Backup & Recovery;Query Optimization & Plans
What is the difference between automatic failover and manual failover in an Always On Availability Group?
IntermediateAutomatic failover happens without any human intervention when a properly configured synchronous secondary replica detects that the primary has failed, immediately promoting itself to become the new primary, while manual failover requires an administrator to explicitly trigger the switch, which is often used for planned maintenance rather than emergencies.
-- Automatic failover requires synchronous commit mode
-- and a configured availability group listener
ALTER AVAILABILITY GROUP MyAG
MODIFY REPLICA ON 'ServerB' WITH (FAILOVER_MODE = AUTOMATIC);
Real-world example
A hospital's patient record system relies on automatic failover so that if the primary database server crashes unexpectedly in the middle of the night, the system recovers on its own without waiting for an administrator to respond.
Backup & Recovery;SQL Server Architecture & Editions
What is an availability group listener, and why is it important for applications connecting to an Always On Availability Group?
IntermediateAn availability group listener provides a single, stable network name and address that applications connect to, regardless of which replica is currently acting as the primary, meaning your application configuration never needs to change even after a failover occurs, since the listener automatically redirects connections to the current primary.
-- Applications connect using the listener name
-- rather than a specific server name
Server=MyAGListener;Database=MyDatabase;
Real-world example
An e-commerce application connects to its database using the availability group listener name, so when a failover happens during a server outage, the application automatically reconnects to the new primary without requiring any configuration changes.
SQL Server Architecture & Editions;Query Optimization & Plans
How do you decide between synchronous commit mode and asynchronous commit mode for a specific replica in an Always On Availability Group?
AdvancedSynchronous commit mode waits for a secondary replica to confirm it has received and written the transaction before the primary considers the transaction complete, guaranteeing zero data loss but adding some latency, while asynchronous commit mode does not wait, offering better performance but with a small risk of losing recent transactions if the primary fails unexpectedly.
ALTER AVAILABILITY GROUP MyAG
MODIFY REPLICA ON 'ServerB' WITH (AVAILABILITY_MODE = SYNCHRONOUS_COMMIT);
ALTER AVAILABILITY GROUP MyAG
MODIFY REPLICA ON 'ServerC' WITH (AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT);
Real-world example
A financial trading platform uses synchronous commit mode for its local disaster recovery replica to guarantee no lost transactions, while using asynchronous commit mode for a distant replica in another region where network latency would otherwise slow down every transaction.
Transactions & ACID;Backup & Recovery
How would you plan a disaster recovery strategy that combines Always On Availability Groups across multiple data centers with regular backups?
AdvancedYou would configure a local synchronous replica for immediate automatic failover during common hardware failures, an asynchronous replica in a geographically distant data center to protect against a full site disaster, and continue taking regular backups of the primary database as an additional layer of protection against issues like accidental data corruption that replication alone cannot fix.
-- Local replica: synchronous commit, automatic failover
-- Remote replica: asynchronous commit, manual failover
-- Backups still run independently on a regular schedule
Real-world example
A multinational retailer keeps a synchronous replica in the same city for fast automatic failover during routine outages, an asynchronous replica in another country for full disaster recovery, and nightly backups to guard against data corruption that could otherwise replicate across both live copies.
Backup & Recovery;SQL Server Architecture & Editions
What are the licensing and edition requirements for using Always On Availability Groups in SQL Server?
IntermediateFull featured Always On Availability Groups with multiple secondary replicas and automatic failover typically require SQL Server Enterprise edition, while a simplified version called basic availability groups, supporting only a single database and two replicas, is available starting with SQL Server Standard edition for organizations with smaller high availability needs.
-- Basic Availability Groups (Standard Edition)
-- support only one database and two replicas total
Real-world example
A small business running SQL Server Standard edition sets up a basic availability group to protect their single most critical database, while a larger enterprise customer uses the full Enterprise edition features to protect dozens of databases with multiple replicas.
SQL Server Architecture & Editions;Backup & Recovery