SQL Server DBA Ultimate Interview Guide – 200+ Expert Questions & Answers | FreeLearning365

SQL Server DBA Ultimate Interview Guide – 200+ Expert Questions & Answers | FreeLearning365

⚙️ SQL Server DBA Ultimate Interview Guide

200+ Expert-Level Questions & Detailed Answers – On‑Prem & Cloud, Latest 2025 Features

FreeLearning365 · The Most Comprehensive DBA Interview Resource

🔹 1. SQL Server 2025 Architecture & New Features (1–20)

1 What are the major new features in SQL Server 2025?

Answer: SQL Server 2025 introduces Azure Arc–enabled management, Ledger tables with improved history, S3‑compatible backup, persistent DOP & parameter sensitive plan optimization, contained availability groups, PolyBase REST API connector, snapshot backup, TDE with Azure Key Vault Managed HSM, and enhanced Query Store on secondaries.

2 Explain Ledger tables in SQL Server 2025.

Ledger tables provide cryptographic proof of data integrity. Every transaction is hashed and linked. Updatable ledger tables maintain a history table automatically. Verify with sys.sp_verify_database_ledger.

CREATE TABLE dbo.Accounts (AccountID INT PRIMARY KEY, Balance DECIMAL(18,2)) WITH (LEDGER = ON);
3 How does S3‑compatible backup work in SQL Server 2025?
CREATE CREDENTIAL [s3://mybucket] WITH IDENTITY = 'S3 Access Key', SECRET = 'mysecret';
BACKUP DATABASE Sales TO URL = 's3://mybucket/sales.bak' WITH FORMAT, COMPRESSION;

Direct backup to any S3‑compatible object storage, including on‑prem MinIO.

4 Describe Azure Arc–enabled SQL Server.

Azure Arc extends Azure management to on‑prem SQL instances. You can inventory, monitor, enforce policies, and even deploy Azure SQL Managed Instance on Kubernetes. It unifies management across hybrid environments.

5 What is Parameter Sensitive Plan optimization (PSP)?

PSP automatically detects parameter values that cause plan quality regressions and creates multiple cached plans for different parameter ranges. Reduces reliance on OPTION (RECOMPILE).

6 How does persistent DOP feedback work?

DOP feedback now persists across restarts. The engine remembers the optimal DOP for a query based on runtime stats and adjusts it gradually, reducing CXPACKET waits.

7 Explain the new PolyBase connectors in SQL Server 2025.

New connectors for REST APIs (query JSON endpoints), Azure Cosmos DB, and improved Oracle/Teradata pushdown. Define external data sources pointing to HTTP endpoints and query with T‑SQL.

8 What are Contained Availability Groups?

Contained AGs replicate server‑level objects (logins, Agent jobs, linked servers) alongside databases. Secondary replicas are fully configured, simplifying failover.

9 How does SQL Server 2025 integrate with Azure Synapse Link?

Synapse Link replicates tables to Azure Synapse Analytics in near real‑time using change feed, enabling analytics on operational data without ETL.

10 Discuss the improvements in TempDB configuration.

TempDB now supports automatic multi‑file configuration based on CPU cores during install. It also uses memory‑optimized metadata tables to reduce system table contention.

11 What is the "Snapshot Backup" feature?

Enables instant backups using storage snapshots on Azure VMs or supported storage. BACKUP DATABASE ... WITH SNAPSHOT and near‑instant restores.

12 SQL Server 2025 on Linux containers – what's new?

Deploy on Kubernetes with Azure Arc–enabled Managed Instance. ARM64 support, fully managed patching, backup, and HA. Official Docker images available.

13 Explain the new Database Scoped Configurations.

Options: LEDGER_DIGEST_STORAGE, PARAMETER_SENSITIVE_PLAN_OPTIMIZATION, MEMORY_OPTIMIZED_TEMPDB_METADATA. They allow per‑database feature control.

14 How has Always Encrypted been enhanced?

Supports secure enclaves in containers, richer operations (LIKE, range) on encrypted columns, online key rotation without downtime.

15 What is the "Query Post‑Execution Plan Analysis" in SSMS?

SSMS 20.x shows estimated vs actual rows, spills, and wait stats directly in the plan viewer, making performance troubleshooting faster.

16 SQL Server 2025 adds support for UTF‑8 collations as default. Why is this important?

UTF‑8 collations reduce storage for English text by up to 50% compared to UTF‑16. Server‑level default UTF‑8 makes international support easier.

17 What is Azure AD Authentication for on‑prem SQL Server?

Arc‑enabled SQL Server can authenticate using Azure AD credentials, enabling unified identity and MFA without on‑prem domain controllers.

18 Describe the improvements in Query Store for SQL Server 2025.

Query Store now available on readable secondaries, automatic time‑based cleanup, and better integration with Intelligent Query Processing for plan forcing history.

19 How to implement a hybrid data platform using SQL Server 2025 and Azure?

Leverage Azure Arc for management, S3 backup to Azure Blob, bidirectional SQL Managed Instance link, and PolyBase for cross‑querying.

20 What is the future of SQL Server Agent?

Agent supports jobs in Kubernetes pods, Azure Automation runbooks, and Logic Apps integration. Managed identities for Azure resources.

🔹 2. Installation, Configuration & Upgrades (21–40)

21 Best practices for installing SQL Server 2025 on Windows Server 2025.
  • Dedicated service accounts (least privilege).
  • Instant File Initialization enabled.
  • TempDB multiple files (1/CPU, max 8).
  • Separate drives for data, log, tempdb.
  • Max server memory 80‑90% of RAM.
  • Latest CU applied.
22 How to perform a silent installation?
Setup.exe /ConfigurationFile=MyConfig.ini /Q /IACCEPTSQLSERVERLICENSETERMS

Configuration file includes features, accounts, paths.

23 Upgrading from SQL Server 2019 to 2025 – key considerations.

Run DMA for breaking changes, test new CE (CE 2025), use Query Store to mitigate plan regressions, upgrade in test first.

24 What is the role of sys.configurations and sp_configure?

sp_configure shows/changes server settings. New in 2025: automatic soft‑NUMA, backup checksum default, etc. Use RECONFIGURE.

25 Explain SQL Server 2025's support for Linux and Docker.

Official Docker image mcr.microsoft.com/mssql/server:2025-latest. Kubernetes with Azure Arc data controller. Full parity with Windows features.

26 How to configure MAXDOP and cost threshold for parallelism?
EXEC sp_configure 'max degree of parallelism', 8;
EXEC sp_configure 'cost threshold for parallelism', 50;
RECONFIGURE;

MAXDOP ≤ cores per NUMA node; CTFP >=50 to avoid trivial parallel plans.

27 How to configure memory for SQL Server?
EXEC sp_configure 'max server memory (MB)', 32768;

Leave 2‑4 GB for OS and other services.

28 Default instance vs named instance?

Default uses port 1433; named uses dynamic port via SQL Browser. Named instance identified by Server\Instance.

29 How to enable Instant File Initialization?

Grant SQL service account "Perform volume maintenance tasks" security policy. Speeds data file growth.

30 Explain the importance of tempdb configuration and file placement.

Place on fast SSD, multiple equally‑sized data files, pre‑size to avoid autogrowth. Monitor with sys.dm_io_virtual_file_stats.

31 How to move system databases (master, model, msdb)?

Change startup parameters for master (-d, -l). For model/msdb, use ALTER DATABASE MODIFY FILE, then move files offline.

32 What is the default port and how to change it?

Default TCP 1433. Change via SQL Server Configuration Manager > TCP/IP properties > IP Addresses tab. Restart service.

33 How to enable and configure Database Mail?
EXEC msdb.dbo.sysmail_add_profile_sp @profile_name='DBA_Profile';
EXEC msdb.dbo.sysmail_add_account_sp ...;
34 How to set up alerts for critical errors (severity 17–25)?

Use SQL Agent alerts: sp_add_alert @severity=17, add operators. Or Windows Event Forwarding.

35 Best practices for storage configuration?

Separate drives for data, log, tempdb. 64KB allocation unit size. RAID10 for data, RAID1 for log. Premium SSD on cloud VMs.

36 How to use PowerShell DSC to deploy SQL Server?

Use SqlServerDsc module with resources SqlSetup, SqlServerConfiguration for consistent, automated deployments.

37 What is the purpose of dbcc checkdb and how to schedule?

Checks database integrity. Schedule weekly with Ola Hallengren's scripts. Use PHYSICAL_ONLY for large DBs.

38 Describe the new "Azure‑enabled" setup experience.

Installation wizard can onboard directly to Azure Arc, enabling cloud management from the start. Provisions Azure extension and optional auto backup.

39 How to migrate on‑prem to SQL Server 2025 with minimal downtime?

Use log shipping or Always On AG for rolling upgrade. Set up 2025 replica, sync, failover. Or Azure DMS for cloud targets.

40 How to validate a SQL Server installation after upgrade?

Check @@VERSION, error log, verify all DBs online, run DBCC CHECKDB on critical DBs, test connectivity, run workload replay.

🔹 3. Security & Compliance (41–60)

41 How to implement Transparent Data Encryption (TDE) in SQL Server 2025?
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '...';
CREATE CERTIFICATE TDECert WITH SUBJECT = 'TDE';
CREATE DATABASE ENCRYPTION KEY WITH ALGORITHM = AES_256 ENCRYPTION BY SERVER CERTIFICATE TDECert;
ALTER DATABASE UserDB SET ENCRYPTION ON;

Can store cert in Azure Key Vault Managed HSM for HSM protection.

42 How to configure Row‑Level Security (RLS)?
CREATE FUNCTION dbo.fn_RLS(@UserID INT) RETURNS TABLE WITH SCHEMABINDING AS RETURN SELECT 1 AS r WHERE @UserID = USER_ID();
CREATE SECURITY POLICY rls_policy ADD FILTER PREDICATE dbo.fn_RLS(UserID) ON dbo.Orders;
43 What is Dynamic Data Masking (DDM)?
ALTER TABLE Customer ALTER COLUMN Email ADD MASKED WITH (FUNCTION = 'email()');

Data masked at presentation layer without changing stored values.

44 How to manage SQL Server logins and users?
CREATE LOGIN [DOMAIN\user] FROM WINDOWS;
CREATE USER [user] FOR LOGIN [DOMAIN\user];
ALTER ROLE db_datareader ADD MEMBER [user];
45 Explain the purpose of a Certificate and Asymmetric Key for module signing.

Use ADD SIGNATURE to grant permissions to a stored procedure without direct user permissions. Enhances security by encapsulating logic.

46 How to implement Always Encrypted with secure enclaves?

Create column master key in Azure Key Vault, define column encryption keys, set encryption on column. Enclaves allow rich computations (LIKE, range).

47 What is SQL Server Audit and how to use it?
CREATE SERVER AUDIT MyAudit TO FILE (FILEPATH = 'C:\Audit\');
CREATE DATABASE AUDIT SPECIFICATION ... FOR SERVER AUDIT MyAudit;
ALTER SERVER AUDIT MyAudit WITH (STATE = ON);
48 How to enforce password policies and complexity?

Create SQL logins with CHECK_POLICY = ON, which uses Windows password policies. Also enforce CHECK_EXPIRATION.

49 How to protect against SQL injection?

Always use parameterized queries with sp_executesql or stored procedures. Avoid string concatenation. Validate input length.

50 What is the purpose of a firewall and how to configure?

Windows Firewall or Azure NSG restricts access to port 1433. Allow only trusted IP ranges.

51 How to use Managed Identity for Azure SQL DB?

Enable managed identity on Azure VM/App Service, create user from external provider, grant permissions. No password management.

52 What are the new security features in SQL Server 2025?

Ledger tables, Azure AD auth for on‑prem, BYOK for TDE in Managed HSM, advanced Always Encrypted enclave operations, and enhanced audit to S3.

53 How to implement Data Classification and compliance?

Use ADD SENSITIVITY CLASSIFICATION to tag columns (e.g., PII, GDPR). Audit and track access with SQL Audit. Use Azure Purview for scanning.

54 Explain the concept of Least Privilege.

Grant only necessary permissions. Use roles (db_datareader, custom roles). Avoid sysadmin for routine tasks.

55 How to secure backups?

Use encrypted backups with certificates. Restrict backup folder access. Store backups in Azure Blob with encryption.

56 What is Cross‑database ownership chaining?

Allows objects to access resources across databases based on ownership. Should be disabled unless carefully managed.

57 How to configure Kerberos authentication for SQL Server?

Register SPNs for SQL service account. Use SETSPN -A MSSQLSvc/server.domain.com. Ensure domain trusts.

58 What is a SQL Server login vs contained database user?

Contained database users exist within the database and authenticate directly, making databases portable. No server login needed.

59 How to encrypt connections with TLS?

Install a trusted certificate on the SQL Server. Set Force Encryption to Yes in configuration manager. Clients use encrypted connections.

60 How to audit privileged operations?

Use Server Audit Specification to track CREATE/ALTER LOGIN, changes to server roles, and database ownership changes.

🔹 4. High Availability & Disaster Recovery (61–85)

61 Explain Always On Availability Groups architecture in SQL Server 2025.

AGs replicate databases via log transport. Up to 8 synchronous replicas, 32 secondaries total. Contained AGs replicate server objects. Read‑scale secondaries support Query Store.

62 What is the difference between synchronous and asynchronous commit?

Synchronous waits for log hardening on secondary before committing – zero data loss. Asynchronous commits immediately, potential for some data loss.

63 How to set up a Basic Availability Group?

Basic AG (Standard edition) supports one database, one secondary. Configuration via wizard or T‑SQL. No read‑scale or multiple DBs.

64 What is a Distributed Availability Group?

Spans two separate AGs across different clusters or geographic locations. Useful for DR and migration across domains.

65 How to perform an online rebuild of indexes in an AG?

Use ALTER INDEX ... REBUILD WITH (ONLINE = ON). Consider MAXDOP to avoid overloading replica.

66 What is a quorum and how does it affect failover?

WSFC quorum ensures enough votes to keep cluster online. Dynamic quorum and file share witness are used to avoid split‑brain.

67 How to configure a listener for an AG?
ALTER AVAILABILITY GROUP [MyAG] ADD LISTENER N'AGListener' (WITH IP ((...), PORT=1433));

Provides a single connection point.

68 Describe the log transport process in AG.

Primary flushes log records to secondary; secondary hardens and acknowledges. Redo thread applies changes. Latency monitored via sys.dm_hadr_database_replica_states.

69 How to monitor AG health using DMVs?
SELECT * FROM sys.dm_hadr_availability_replica_states;
SELECT * FROM sys.dm_hadr_database_replica_states;
70 What is the difference between automatic and manual failover?

Automatic failover requires synchronous commit and a configured partner. Manual requires DBA intervention.

71 How to set up Log Shipping?

Primary takes log backups, copies to secondary, restores with NORECOVERY or STANDBY. Simple, supports multiple secondaries.

72 How to fail over a log‑shipped database?

Restore the last log with RECOVERY. Redirect applications. Point‑in‑time recovery possible.

73 What is the difference between RPO and RTO?

RPO = max acceptable data loss (time). RTO = max acceptable downtime. Design HA/DR to meet both.

74 How does failover cluster instance (FCI) work?

Shared storage, multiple nodes. Instance fails over to another node. Protects at server level. Requires WSFC.

75 What is the role of tempdb in an AG?

Tempdb is not replicated; each replica has its own. Ensure identical tempdb configuration for performance consistency after failover.

76 How to handle database snapshots in an AG?

Snapshots can be created on secondary for reporting. Requires synchronization. Not supported on primary.

77 What are the prerequisites for Always On AG?

Enterprise Edition (or Standard for Basic AG), WSFC, identical server collation, full recovery model, and a domain (unless workgroup cluster in 2025).

78 How to set up a multi‑subnet AG?

Configure cluster with cross‑subnet failover, use RegisterAllProvidersIP=0 for listeners, adjust HostRecordTTL.

79 Describe the new clusterless availability group in SQL Server 2025.

Supports AG without WSFC, using Kubernetes or Pacemaker for orchestration. Simplifies deployment on Linux and containers.

80 How to automate failover with scripts?

Use ALTER AVAILABILITY GROUP [MyAG] FAILOVER; in a job triggered by health detection scripts (e.g., DBATools).

81 What is the difference between a replica and a secondary?

A replica is a participating instance; a secondary is a replica that hosts copies and can be read‑only if configured.

82 How to test DR plan regularly?

Perform planned manual failover in a maintenance window. Use DR drills to validate RPO/RTO, document steps.

83 How to manage backups in an AG?

Configure backup preferences: primary only, secondary only, or prefer secondary. Use sys.fn_hadr_backup_is_preferred_replica.

84 What is a read‑scale availability group?

Allows readable secondaries without high availability. No cluster required, but no automatic failover. Good for offloading reporting.

85 How to implement HA/DR in Azure SQL?

Azure SQL DB uses built‑in HA with 99.995% SLA. Active geo‑replication for DR. SQL Managed Instance uses auto‑failover groups.

🔹 5. Performance Tuning & Monitoring (86–110)

86 How do you identify and resolve a CPU bottleneck?

Check wait stats for SOS_SCHEDULER_YIELD. Use Query Store to find high‑CPU queries. Tune indexes, remove scalar UDFs, consider Resource Governor.

87 What tools would you use to monitor a slow query?

Actual execution plan with STATISTICS IO/TIME, Query Store, DMVs (sys.dm_exec_query_stats), Extended Events, and sp_whoisactive.

88 How to read an execution plan?

Look for clustered index scans (SCAN), key lookups, high estimated vs actual rows, thick arrows (data flow). Identify the most expensive operator.

89 What is a missing index and how to find it?

Execution plan shows missing index hints. DMVs: sys.dm_db_missing_index_details. Always review before implementing.

90 Explain the difference between an index seek and scan.

Seek navigates B‑tree directly for selective predicates; scan reads entire leaf level. Seek usually more efficient.

91 How to use Query Store to force a plan?
EXEC sp_query_store_force_plan @query_id = 10, @plan_id = 50;

After verifying the plan is better.

92 What are wait statistics and how do you analyze them?
SELECT wait_type, wait_time_ms FROM sys.dm_os_wait_stats WHERE wait_type NOT LIKE '%SLEEP%' ORDER BY wait_time_ms DESC;

Focus on PAGEIOLATCH, WRITELOG, CXPACKET, LCK_*.

93 How to monitor tempdb contention?

Check PAGELATCH_* waits on tempdb. Ensure multiple data files, trace flag 1118 (if needed), and memory‑optimized tempdb metadata in 2025.

94 What is parameter sniffing and how to fix it?

Plan compiled for atypical parameter values. Fixes: OPTION (RECOMPILE), OPTIMIZE FOR UNKNOWN, local variables, or PSP in 2025.

95 How to use Extended Events for performance?
CREATE EVENT SESSION [HighCPU] ON SERVER ADD EVENT sqlserver.rpc_completed (WHERE sqlserver.cpu_time > 5000000) ADD TARGET ring_buffer;
96 Explain the purpose of Resource Governor.

Limits CPU/memory per workload group. Classify connections by application, login, etc. Prevents a single query from consuming all resources.

97 How to find the most expensive queries by IO?
SELECT TOP 10 total_logical_reads/execution_count AS avg_reads, text FROM sys.dm_exec_query_stats CROSS APPLY sys.dm_exec_sql_text(sql_handle) ORDER BY avg_reads DESC;
98 What are the best practices for index maintenance?

Use Ola Hallengren scripts. Reorganize 5‑30% fragmentation, rebuild >30%. Update statistics after. Use online operations.

99 How to troubleshoot blocking and deadlocks?

Use sp_who2, sys.dm_exec_requests with blocking_session_id. Deadlock graphs via Extended Events or trace flag 1222.

100 Explain the In‑Memory OLTP technology.

Memory‑optimized tables and natively compiled stored procedures for high‑speed OLTP. Requires separate filegroup. Reduces latch contention.

101 How to monitor memory usage and detect pressure?

sys.dm_os_process_memory, sys.dm_os_memory_clerks. Page life expectancy (< 300s) indicates memory pressure.

102 What is the role of the buffer pool and plan cache?

Buffer pool caches data pages; plan cache stores execution plans. Flushing them causes recompilations and physical reads.

103 How to use Database Tuning Advisor (DTA)?

Provide a workload trace; DTA recommends indexes/statistics. Always evaluate impact, don't blindly apply.

104 How to capture a workload for replay?

Use SQL Server Profiler (deprecated) or Extended Events to capture RPC/SP statements. Replay with Distributed Replay or SQL Workload Tools.

105 What are columnstore indexes and when to use them?

Store data column‑wise, great for large aggregations (DW). Clustered columnstore offers high compression and batch mode processing.

106 How to use the new Query Store hints in SQL Server 2025?
EXEC sp_query_store_set_hints @query_id = 10, @value = N'OPTION (HASH JOIN)';

Override plan without code changes.

107 How to monitor and optimize index fragmentation?
SELECT * FROM sys.dm_db_index_physical_stats(db_id(), object_id, null, null, 'LIMITED');

Rebuild/reorganize based on thresholds.

108 What is the benefit of using OPTION (RECOMPILE)?

Generates a new plan for each execution, ideal for queries with highly variable parameters that cause bad parameter sniffing. Trade‑off: increased CPU for compilation.

109 How to implement an effective monitoring solution?

Combine built‑in tools (Query Store, DMVs), third‑party (SolarWinds, Redgate), and custom scripts collecting to a central monitoring database with alerts.

110 How to use performance counters (PerfMon)?

Key counters: SQLServer:Buffer Manager\Page life expectancy, SQLServer:Memory Manager\Target Server Memory, Processor\% Processor Time, PhysicalDisk\Avg. Disk sec/Read.

🔹 6. Backup & Restore Strategies (111–130)

111 What are the different recovery models and when to use them?

Full: point‑in‑time recovery, all operations logged. Simple: no log backups, only full/differential. Bulk‑logged: minimally logs bulk ops. Use Full for production.

112 How to perform a full database backup with compression?
BACKUP DATABASE [MyDB] TO DISK = 'D:\Backups\MyDB_Full.bak' WITH COMPRESSION, CHECKSUM, INIT;
113 Explain the difference between full, differential, and transaction log backups.

Full: entire database. Differential: changes since last full. Log: all transactions since last log backup. Combine for point‑in‑time recovery.

114 How to restore to a point in time?
RESTORE DATABASE [MyDB] FROM DISK = 'Full.bak' WITH NORECOVERY;
RESTORE LOG [MyDB] FROM DISK = 'Log1.trn' WITH NORECOVERY;
RESTORE LOG [MyDB] FROM DISK = 'Log2.trn' WITH STOPAT = '2025-06-24 10:30:00', RECOVERY;
115 How to use backup to URL (Azure Blob)?
BACKUP DATABASE [MyDB] TO URL = 'https://myaccount.blob.core.windows.net/backups/MyDB.bak' WITH CREDENTIAL = 'AzureCred', COMPRESSION;
116 What is a striped backup and why use it?

Splits backup across multiple files for parallelism and to overcome file size limits. TO DISK = 'file1,file2'.

117 How to verify backup integrity?
RESTORE VERIFYONLY FROM DISK = 'MyDB.bak';

Use CHECKSUM during backup for additional protection.

118 Explain tail‑log backup.

Backup of the active transaction log after a disaster, before restore. Ensures minimal data loss. BACKUP LOG ... WITH NORECOVERY.

119 How to set up an automated backup strategy?

Use Ola Hallengren's maintenance scripts or SQL Agent jobs. Full weekly, differential daily, log every 15‑30 min. Cleanup old files.

120 What is the difference between COPY_ONLY backup?

Does not affect the log chain or differential base. Used for ad‑hoc backups without disrupting the regular schedule.

121 How to restore a database to a different server with different file paths?
RESTORE DATABASE [NewDB] FROM DISK = 'backup.bak' WITH MOVE 'DataFile' TO 'D:\Data\NewDB.mdf', MOVE 'LogFile' TO 'E:\Log\NewDB.ldf';
122 How to use snapshot backups in Azure?
BACKUP DATABASE [MyDB] TO VIRTUAL_DEVICE = 'AzureSnapshot' WITH SNAPSHOT, METADATA_ONLY;

Near‑instant restore.

123 Explain database recovery phases.

Analysis: identifies log records. Redo: applies committed changes. Undo: rolls back uncommitted. Fast recovery in 2025 reduces undo time.

124 How to manage transaction log file growth?

Ensure regular log backups in Full recovery. Monitor log size, avoid autogrow churn. Set appropriate size and growth increments.

125 What is the backup checksum option?

Adds a checksum to each page in the backup, allowing verification during restore. Detects corruption. Use WITH CHECKSUM.

126 How to back up to an S3‑compatible endpoint?
BACKUP DATABASE [MyDB] TO URL = 's3://mybucket/backup.bak' WITH CREDENTIAL = 'S3Cred', FORMAT, COMPRESSION;
127 How to encrypt backups?
CREATE CERTIFICATE BackupEncryptCert ...;
BACKUP DATABASE [MyDB] TO DISK = '...' WITH ENCRYPTION (ALGORITHM = AES_256, SERVER CERTIFICATE = BackupEncryptCert);
128 Explain media sets and backup families.

Media set is a collection of backup devices. Backup set contains data from a single backup operation. Families allow mirrored backups.

129 How to perform a page restore?
RESTORE DATABASE [MyDB] PAGE = '1:57' FROM DISK = 'log.trn' WITH NORECOVERY;

Useful for corrupted pages without full restore.

130 How to implement a backup retention policy for compliance?

Store backups for required time, possibly in immutable storage (Azure Blob with legal hold). Use lifecycle management to auto‑delete.

🔹 7. Automation & Maintenance (131–150)

131 What is Ola Hallengren's maintenance solution?

Set of stored procedures for index optimize, database integrity check, and backup. Highly configurable and widely used. IndexOptimize, DatabaseIntegrityCheck, etc.

132 How to schedule jobs with SQL Server Agent?
EXEC msdb.dbo.sp_add_job ...; EXEC msdb.dbo.sp_add_jobstep ...; EXEC msdb.dbo.sp_add_schedule ...;

Or use SSMS GUI.

133 How to create a maintenance plan using SSMS?

Right‑click Maintenance Plans > New. Drag tasks (Back Up, Rebuild Index). Set schedules. Under the hood uses Integration Services.

134 What is the difference between a job step of type "Transact‑SQL" and "PowerShell"?

T‑SQL runs SQL commands; PowerShell allows running scripts and accessing OS functions. PowerShell steps can use SQLPS module.

135 How to automate index rebuild with MAXDOP and online?
EXEC dbo.IndexOptimize @Databases = 'USER_DATABASES', @FragmentationLow = NULL, @FragmentationMedium = 'REORGANIZE', @FragmentationHigh = 'REBUILD', @UpdateStatistics = 'ALL', @MaxDOP = 4, @Online = 1;
136 How to automate statistics updates?

Enable auto update statistics (default). Use Ola's IndexOptimize with @UpdateStatistics = 'ALL'. Or custom script using sys.dm_db_stats_properties.

137 How to implement a job to clean up old backup files?
EXEC master.dbo.xp_delete_file 0, 'D:\Backups', 'bak', '2025-06-01T00:00:00';

Or use PowerShell step.

138 How to use DBATools PowerShell module for automation?

Commands: Backup-DbaDatabase, Restore-DbaDatabase, Test-DbaLastBackup. Automate tasks across many servers easily.

139 What is a database snapshot and how can it be used for maintenance?

Read‑only point‑in‑time copy. Useful before large updates; can revert via restore from snapshot. Minimal space overhead.

140 How to implement a sliding window partition maintenance?

Create new partition, switch oldest partition out to archive table, merge empty partition. Automate with stored procedure called by Agent.

141 How to set up a central management server (CMS)?

Register multiple servers in SSMS > Central Management Servers. Run multi‑server queries and apply policies.

142 What are Policy‑Based Management policies?

Define rules (e.g., naming conventions, recovery model) and evaluate against servers. Can prevent violations or just report.

143 How to use PowerShell to deploy a SQL Server patch?
Start-Process -FilePath "CU.exe" -ArgumentList "/quiet /IAcceptSQLServerLicenseTerms" -Wait
144 How to automate restores for development databases?

Create a job that restores the latest production backup onto a dev server, with REPLACE, and then masks/scrubs sensitive data.

145 How to monitor agent job failures and send alerts?

In SQL Agent, configure notifications on job failure to email an operator. Or use msdb.dbo.sp_send_dbmail in the final step.

146 How to use Azure Automation with SQL Server?

Hybrid Runbook Worker can run PowerShell scripts against on‑prem SQL. Integrate with Azure Monitor for alerts.

147 Explain the new automation features in SQL Server 2025.

Agent supports Kubernetes jobs, Logic Apps integration, managed identities for Azure. Script task steps can use PowerShell 7.

148 How to perform database consistency checks in parallel?

Use DBCC CHECKDB with MAXDOP or run multiple checks on different databases simultaneously via multiple Agent jobs.

149 What is the purpose of sp_cycle_errorlog?

Archives current error log and starts a new one. Helps avoid large logs. Schedule weekly.

150 How to automate DBCC commands using DBATools?
Invoke-DbaDiagnosticQuery -SqlInstance localhost | Export-DbaDiagnosticQuery -Path C:\reports

🔹 8. Cloud Integration & Azure SQL (151–180)

151 What are the main Azure SQL offerings?

Azure SQL Database (PaaS), Azure SQL Managed Instance (near‑100% compatibility), and SQL Server on Azure VM (IaaS).

152 How does Azure SQL Database differ from on‑prem SQL Server?

Built‑in HA, automatic backups, scaling (vCore/DTU), no direct OS/file access. TDE enabled by default. Some T‑SQL differences.

153 How to migrate an on‑prem database to Azure SQL Managed Instance?

Use Azure Database Migration Service or log replay service. Backup to URL and restore. Or use transactional replication.

154 Explain the Azure SQL Managed Instance link feature.

Replicates database from SQL Server 2019+ to Managed Instance in real time, enabling hybrid DR and near‑zero downtime migration.

155 How to configure Azure AD authentication for Azure SQL?

Set Azure AD admin in portal. Create users CREATE USER [user@domain] FROM EXTERNAL PROVIDER. Use Active Directory Interactive connection.

156 What is the Azure SQL Hyperscale architecture?

Separates compute, log, and storage. Enables very large databases (up to 100TB) with fast scaling and nearly instantaneous backups.

157 How to configure geo‑replication for Azure SQL Database?

Create a secondary database in another region. Active geo‑replication allows up to 4 readable secondaries. Failover via portal or T‑SQL.

158 Explain auto‑failover groups.

Group of databases that fail over together across regions. Provides a single endpoint, handles replication and connection routing.

159 How to monitor Azure SQL performance?

Use Query Performance Insight, Azure Monitor metrics, Intelligent Insights, and Extended Events. Also DMVs like sys.dm_db_resource_stats.

160 What is automatic tuning in Azure SQL?

Azure can automatically force good plans, create/drop indexes based on workload analysis. Turn on in portal.

161 How to implement elastic pools?

Group databases with varying usage patterns to share resources cost‑effectively. Define pool size and per‑db min/max.

162 How to secure Azure SQL with firewall rules and VNet endpoints?

Configure server‑level firewall IP rules. For private access, use VNet service endpoints or Private Link.

163 What is the role of Azure Key Vault for TDE in Azure SQL?

Stores the TDE protector key. Enables Bring Your Own Key (BYOK). Managed Instance also supports Managed HSM.

164 How to automate deployment of Azure SQL using ARM templates or Terraform?

Define desired state (server, DB, firewall rules) in code. Deploy via CI/CD pipeline for consistent environments.

165 How to use PolyBase to query data in Azure Blob Storage?
CREATE EXTERNAL DATA SOURCE blob_ds WITH (LOCATION = 'wasbs://...');
CREATE EXTERNAL TABLE ... ;
166 Explain the difference between DTU and vCore purchase models.

DTU: bundled measure of CPU, IO, memory. vCore: independent scaling of compute and storage. vCore offers Azure Hybrid Benefit.

167 How to set up cross‑database queries in Azure SQL DB using elastic query?

Create external data source pointing to another Azure SQL DB. Create external tables. Queries can join across shards.

168 How to handle backups in Azure SQL?

Automatic backups: full weekly, differential 12‑24h, log every 5‑10 min. Retention 7‑35 days. Long‑term retention (LTR) for up to 10 years.

169 What is Azure SQL Ledge?

Provisioned as a database option in Azure SQL. Provides blockchain‑like tamper‑evident storage. Useful for compliance.

170 How to migrate to Azure SQL with minimal downtime?

Use Azure SQL Managed Instance link or transactional replication. Set up bi‑directional sync, cutover after data catches up.

171 How to use Azure Data Studio for managing SQL Server?

Cross‑platform tool with extensions for backup, performance dashboards, and Notebooks. Especially useful for Linux and cloud.

172 Explain the Azure Arc data controller and its benefits for SQL Managed Instance.

Deploys Azure SQL Managed Instance on any Kubernetes cluster. Provides automated updates, backup, and monitoring via Azure portal.

173 What is the SQL Server Agent in Azure SQL Managed Instance?

Fully functional SQL Agent, similar to on‑prem. Can run T‑SQL, PowerShell, SSIS packages. Managed via portal.

174 How to monitor Azure SQL with Azure Monitor and Alerts?

Create alert rules on metrics like dtu_consumption_percent, storage_percent. Send to email, webhook, or Logic Apps.

175 How to implement a hybrid backup strategy using Azure?

Backup on‑prem to URL (Azure Blob) or S3. Use Azure Backup for SQL Server on VMs for integrated management.

176 What is Azure Synapse Link for SQL Server 2025?

Replicates tables to Synapse Analytics in near real‑time, using change feed. Enables analytics without ETL.

177 How to use Azure Policy for SQL Server compliance?

Define policies (e.g., enforce TDE, audit) and assign to Azure Arc–enabled SQL instances. Compliance results in Azure portal.

178 How to perform disaster recovery drills in Azure SQL?

Initiate a planned failover of a geo‑replicated database or auto‑failover group. Validate application connectivity and data integrity.

179 Explain the security features available in Azure SQL Managed Instance.

Azure AD auth, TDE with BYOK, Advanced Threat Protection, vulnerability assessment, dynamic data masking, and row‑level security.

180 What is the future of SQL Server in the cloud?

Deeper integration with Azure Arc, serverless computing, AI‑driven tuning, and seamless hybrid operations. SQL Server will be fully managed across environments.

🔹 9. Troubleshooting & Advanced Scenarios (181–200)

181 How to troubleshoot a database that won't start?

Check error log, verify file paths, ensure disk space, look for corruption. Emergency mode repair with ALTER DATABASE ... SET EMERGENCY and DBCC CHECKDB.

182 What steps do you take when a query suddenly runs slow?

Check current waits, look at execution plan, compare with previous plans in Query Store. Recompile if needed, check statistics, look for blocking.

183 How to resolve a tempdb contention issue?

Add multiple tempdb data files, enable trace flag 1118 (older versions), ensure equal sizing, and in 2025 enable memory‑optimized tempdb metadata.

184 How to handle a suspect database?

Review error log, run DBCC CHECKDB with repair options if necessary (last resort). Restore from backup if repair not possible.

185 How to investigate a deadlock?

Capture deadlock graphs via trace flag 1222 or Extended Events. Analyze locked resources, fix by adding indexes or reordering transactions.

186 What is the cause of a log full error (9002)?

Transaction log out of space. Caused by long‑running transaction, log backups not taken, or large operations. Fix: backup log, increase size, shrink (temporarily).

187 How to troubleshoot an always‑on AG synchronization issue?

Check sys.dm_hadr_database_replica_states for synchronization health. Look for network latency, suspended movement, or disk space. Resume data movement if suspended.

188 How to fix a corrupt page?

Restore the page from a good backup if available. Otherwise, use DBCC PAGE to examine, possibly use DBCC WRITEPAGE (extreme).

189 How to resolve an out‑of‑memory condition?

Increase max server memory if appropriate, identify memory‑intensive queries, free plan cache, or use Resource Governor.

190 What is the procedure for a disaster recovery situation?

Assess the damage, decide on restoration (tail‑log backup if possible), restore full/diff/logs, bring databases online, test, and communicate.

191 How to troubleshoot high MSDTC usage?

Check for distributed transactions, ensure MSDTC service is running, configure firewall, and monitor with sys.dm_tran_active_transactions.

192 How to identify the cause of a SQL Server crash?

Analyze error log, Windows event logs, memory dumps. Look for stack dumps. Use SQL Server Setup to repair if needed.

193 What to do when a database is in "recovery pending" state?

Check error log, ensure database files accessible, run ALTER DATABASE ... SET EMERGENCY, then DBCC CHECKDB. Restore if necessary.

194 How to troubleshoot connectivity issues?

Verify server is running, port accessible (telnet, test‑netconnection), check firewall, SQL Browser for named instances, and login permissions.

195 How to handle a VLF explosion in the transaction log?

Too many VLFs can slow recovery and log operations. Fix by growing log in appropriate increments to reduce VLF count. DBCC LOGINFO to check.

196 How to diagnose high IO latency?

Use sys.dm_io_virtual_file_stats to see read/write stall. Check physical disk counters. Move to faster storage if needed.

197 Explain a scenario: frequent auto‑growth causing performance spikes.

Pre‑size data and log files to avoid growth during peak. Monitor growth events with default trace or Extended Events. Set growth increments to reasonable MB.

198 How to investigate a blocking chain?
SELECT * FROM sys.dm_exec_requests WHERE blocking_session_id > 0;

Kill the head blocker after verifying. Long term: add indexes, tune queries, use snapshot isolation.

199 How to use the DAC (Dedicated Admin Connection)?
sqlcmd -S admin:server\instance -U sa -P ... 

Used when server is unresponsive. Limited resources.

200 How to build a comprehensive troubleshooting runbook?

Document common issues: CPU, memory, IO, blocking, AG sync, backup failures. Include step‑by‑step diagnostic queries and escalation paths.

🔹 10. Bonus Labs & Real‑World DBA Challenges (201–210)

201 Lab: Set up an Always On Availability Group with 3 replicas (2 sync, 1 async).

Build WSFC, enable AG feature, create endpoints, prepare databases, create AG with replicas, join secondaries, add listener. Test failover.

202 Lab: Implement TDE and test recovery on another server.

Encrypt database, backup cert and key, restore on different server, decrypt with cert. Validate data.

203 Lab: Automate backups and restores using DBATools.
$splat = @{ SqlInstance = 'ProdServer'; Path = '\\backupshare\'; Type = 'Full'; CompressBackup = $true }
Backup-DbaDatabase @splat
204 Lab: Build a monitoring dashboard with Power BI over DMVs.

Use sys.dm_os_performance_counters, Query Store, wait stats. Schedule data collection, visualize trends.

205 Lab: Configure Azure Arc for on‑prem SQL and enforce policies.

Install Azure Arc agent, connect SQL Server, create Azure Policy assignments (e.g., require TDE). Review compliance.

206 Lab: Perform a point‑in‑time restore to recover dropped table.

Restore full, differential, log backups with STOPAT. Extract data and re‑insert into production.

207 Lab: Simulate a corrupted page and repair using page restore.

Corrupt a page with hex editor (test only!), take tail‑log backup, restore page from earlier log backup.

208 Lab: Use Query Store to force a better plan and measure performance.

Identify regressed query, find plan with lower avg duration, force it. Compare before/after execution times.

209 Lab: Implement row‑level security for multi‑tenant app.

Create predicate function, security policy. Test with different user contexts. Ensure no data leakage.

210 Lab: Automate DBCC CHECKDB across multiple instances with central logging.
Invoke-DbaDiagnosticQuery -SqlInstance 'server1','server2' | Out-File -FilePath report.txt

💡 Expert DBA Answer Formula: Situation → Action → Result. Always back answers with DMVs, T‑SQL, and real‑world impact.

✔️ Use metrics (seconds, IO, waits). ✔️ Demonstrate security & HA awareness. ✔️ Show troubleshooting methodology.

🚀 You've now absorbed over 200 advanced SQL Server DBA interview questions. Go ace that interview!

🔗 Go to Job Interview Portal – FreeLearning365

© FreeLearning365 – The Ultimate SQL Server DBA Interview Preparation Resource. Share this guide with your network.

Post a Comment

0 Comments