Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
710 views

SQL DBA Interview Questions

The document contains questions and answers related to SQL Server system databases, backups, stored procedures troubleshooting, database maintenance, and other SQL Server concepts. Some key points: - The system databases in SQL Server include master, msdb, model, resource, and tempdb. They perform important system-level functions. - Backup types in SQL Server include full, differential, log, file/file group, copy-only, and partial backups. - To troubleshoot a slow stored procedure, one would check for blocking, outdated statistics, missing indexes, index fragmentation, and inefficient query patterns. - TRUNCATE removes all rows from a table instantly while DELETE removes rows based on a condition

Uploaded by

sowji.yeturi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
710 views

SQL DBA Interview Questions

The document contains questions and answers related to SQL Server system databases, backups, stored procedures troubleshooting, database maintenance, and other SQL Server concepts. Some key points: - The system databases in SQL Server include master, msdb, model, resource, and tempdb. They perform important system-level functions. - Backup types in SQL Server include full, differential, log, file/file group, copy-only, and partial backups. - To troubleshoot a slow stored procedure, one would check for blocking, outdated statistics, missing indexes, index fragmentation, and inefficient query patterns. - TRUNCATE removes all rows from a table instantly while DELETE removes rows based on a condition

Uploaded by

sowji.yeturi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Rajasekhar Reddy Bolla WhatsApp: +91 9966246368

(find me in LinkedIn & YouTube)

Q1) What are system databases?

A1)
Master
Records all the system-level information for an instance of SQL Server.
Database
Msdb
Is used by SQL Server Agent for scheduling alerts and jobs.
Database
Is used as the template for all databases created on the instance of SQL Server.
Model
Modifications made to the model database, such as database size, collation, recovery
Database
model, and other database options, are applied to any databases created afterward.
Is a read-only database that contains system objects that are included with SQL
Resource
Server. System objects are physically persisted in the Resource database, but they
Database
logically appear in the sys schema of every database.
Tempdb
Is a workspace for holding temporary objects or intermediate result sets.
Database

Q2) What are various types of backups available in SQL Server?

A2)
• Copy-only backup: A special-use backup that is independent of the regular sequence of
SQL Server backups.
• Differential backup: A data backup that is based on the latest full backup of a complete
or partial database or a set of data files or filegroups (the differential base) and that
contains only the data extents that have changed since the differential base.
• Full back up: A data backup that contains all the data in a specific database or set of
filegroups or files, and also enough log to allow for recovering that data.
• Log backup: A backup of transaction logs that includes all log records that were not
backed up in a previous log backup. (full recovery model)
• File backup: A backup of one or more database files or filegroups.
• Partial backup: Contains data from only some of the filegroups in a database, including
the data in the primary filegroup, every read/write filegroup, and any optionally-
specified read-only files.

Q3) How can you take backup of a SQL server database?

A3)
a. You can use TSQL command BACKUP Database.
b. You can use SSMS to right click on a database and then take backup.
c. You can use 3 party utilities to take backups of database or even take snapshot backups
rd

of database.

Q4) If a stored procedure is running slow then what are the basics things you will check
to fix it?

A4)
a. Check whether it is blocked by some session.
b. Check if the statistics are updated on the underlying tables.
c. Check if the tables do not have a missing index.
d. Check if the indexes are not fragmented.
e. Check if the stored procedure follows common best practices such not using
SELECT *, DISTINCT, UNION and unnecessary joins.

Q5) What is the difference between TRUNCATE and DELETE?

A5) Delete command removes the rows from a table based on the condition that we provide with a
WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in
the table after we run the truncate command.

Q6) What is an IDENTITY column?

Reach us on any help and support (Job & Interview) on SQL Server (On-premise &Azure)
Rajasekhar Reddy Bolla WhatsApp: +91 9966246368
(find me in LinkedIn & YouTube)
A6) An identity column is one with value being generated automatically based on the initial SEED
value & increment.

Q7) What is RDBMS?


A7) Relational Database Management system (RDBMS) is a database management system (DBMS)
that is based on the relational model. Data from relational database can be accessed or
reassembled in many different ways without having to reorganize the database tables. Data from
relational database can be accessed using an API , Structured Query Language (SQL).

Q8) What is SQL?


A8) Structured Query Language(SQL) is a language designed specifically for communicating with
databases. SQL is an ANSI (American National Standards Institute) standard.

Q9) How can you check a database for corruption?


A9) You can DBCC CHECKDB, DBCC CHECKTable, DBCC CheckAlloc

Q10) When do we use UPDATE_STATISTICS?


A10) When there has been a huge amount of data change on the underlying tables then we can
use this command to update the data distribution or statistics information for optimized query plan
generation.

Q11) How can you rename a database using TSQL?


A11) Sp_renamedb

Q12) What is the purpose of JOIN in SQL server?


A12) JOIN is used to put data from two or more tables together in a single result set.

Q13) Name few built-in functions in SQL server?


A13) SUM(), MAX(), MIN(), COUNT()

Q14) What are various recovery models in SQL server?


A14) Simple, Full and Bulk-logged

Q15) Can you take transaction log backup in Simple recovery model?
A15) No

Q16. Which activity in SQL server you can relate with Durability property of ACID property? "Check
all that apply"
(a) Running Checkdb and confirming that database has no issue
(b) DCCC opentran
(c) Instance or Media Recovery
(d) Checkpoint

Ans : C

Q17 : Name some isolation level which follows pessimistic concurrency model?
Ans : A) Read committed
b) Repeatable Read
c) Read Uncommitted
d) Serializable

Q18) How can we migrate master database from one disk location to another (say C:\
drive to D:\ drive)
A18) Stop the SQL instance, manually copy the data and log files (mdf and ldf) to the new
location, edit the startup parameters –d and –l to the new path and start the SQL instance.

Q19) How can we migrate temp database from one disk location to another (say C:\
drive to D:\ drive)

Reach us on any help and support (Job & Interview) on SQL Server (On-premise &Azure)
Rajasekhar Reddy Bolla WhatsApp: +91 9966246368
(find me in LinkedIn & YouTube)
A19) Use the ALTER DATABASE command to change the location of tempdb files to the new
location and simply restart the SQL instance.

Q20) How can we change the port of SQL instance? ...Does it require a restart of the
service?
A20) Port of a SQL instance can be changed from SQL Server Configuration Manager tool. Yes it
requires a restart of the SQL service.

Q21) If the Resource database files gets damaged or corrupted then how do we fix this
issue?
A21) If we have another SQL instance of the exact same version then we can simply copy the mdf
file of Resource database from that instance and replace it in place of the damaged file.
If we do not have a SQL instance of the same version then we need to rebuild the instance.

Q22) Which isolation level causes Phantom reads in SQL and which other isolation level
can we use to prevent it?
A21) Repeatable Read isolation level can result in Phantom reads and Serializable isolation level
can help prevent it.

Q23) How will you troubleshoot if some error is encountered during installation or
patching of SQL instances?
A23) Need to check the error thrown during the installation activity. Summary of installation of
patching is logged into a file named Summary.txt in Bootstrap folder of SQL installation path.
The Details.txt path gives more details about the installation logs. Depending upon the errors seen
in these files we will take our next step of troubleshooting.

Q24) Can you state at least one reason for which SQL patching can fail?
A24) Missing MSI and MSP files, damaged installation media, permission issues

Q25) How will you plan patching of a SQL instance on a cluster?


A25) We will patch the passive node first, then failover all the resources to it and patch the
previous active node.

Q26) What is the difference between High Availability offered by Failover Clustered
instances (FCI) and AlwaysOn?
A26) FCI offers HA at the SQL instance level and AlwaysON offers it at the database level.

Q27) Since which version of SQL Server the Alwayson feature was added?
A27) Starting with SQL Server 2012 the Alwayson feature was added.

Q28) How can we capture details of Deadlock event in SQL Server?


A28) By enabling trace flags 1222 or 1204. It prints the deadlock graphs in SQL Errorlog file.

Q29) What different types of Replication we have in SQL server?


A29) Snapshot Replication, Transactional Replication, Merge Replication, Peer-to-Peer Replication.

Q30) What is the default ports of SQL instance, SQL Browser service and SQL mirroring
endpoint?
A30) SQL instance = 1433, SQL Browser service = 1434, Mirroring Endpoint = 5022.

Q31) What is the easiest way to determine the SQL instance installed on the server ?
(the numbers of instances and their names)
A31) From services.msc we can see all the installed SQL instances. The same can be done from
SQL Server Configuration Manager and Registry keys.

Q32) What different types of Query Joins are available in SQL Server?
A32) Nested Loops, Merge Joins, Hash Joins.

Q32) Which DMVs in SQL give information about current sessions?


A32) sys.sysprocesses, sys.dm_exec_sessions

Reach us on any help and support (Job & Interview) on SQL Server (On-premise &Azure)
Rajasekhar Reddy Bolla WhatsApp: +91 9966246368
(find me in LinkedIn & YouTube)

Second round Screening questions ( Trick questions)


Q1. To increase a data file size from 100 GB to 200 GB it took 1 minutes so how much time it will
take to increase Log file size from 100 GB to 200 GB if it is located on same disk\HARDWARE\OS?

A1. Log File Growth will be slower as it cannot take advantage of Instant File Initialization.

Q2. Will SQL SERVER Service start If model database corrupted? NO, because to create tempdb we
need model database which act like a template.
Will SQL SERVER Service start If someone deleted tempdb data & log files? Yes because SQL
SERVER will recreate files again.

Q3. You have database mirroring configured between Server1 & Server2 in High Safety mode. For
example if we have failover and now Server2 become Principal then how application will connect to
new Principal Server?

A3. In Connection string we need to specify Failover Partner so application can connect to Server2 if
Server1 not responding.

string cs = @”Data Source=Server1;Failover Partner=Server2;Initial Catalog=MirroredDabase”;

Q4. Consider this scenario, we have AlwaysOn configured between ServerA and ServerB in
asynchronous-commit mode. Customer is complaining that after ServerA crashed they don't see
ServerB taking over as new Primary. How do you help customer?

A4. Automatic failover requires that both the primary replica and the target secondary replica are
running under synchronous-commit mode with the failover mode set to "Automatic".

PREPARATION CONCEPTS:

Database Architecture (Must Have)

-----------------------------------------------------------------------

Checkpoint:

Lazy Writer:

Recovery phase :

Use of T_Log File:

What are VLFs:

Reach us on any help and support (Job & Interview) on SQL Server (On-premise &Azure)
Rajasekhar Reddy Bolla WhatsApp: +91 9966246368
(find me in LinkedIn & YouTube)

Disaster Recovery, SQL Server Setup & Administration (Must Have)

----------------------------------------------------------------------------------------------

Type of backups: Diff and T-Log backup.

When and How to take them:

Check point :

Lazy write :

Log shipping :

============

Tuff file :

Installation :

=============

Bootstrap : ,Event log .

SQL Server not starting :

Troubleshooting Scenarios: Area of Concern.

----------------------------------------------------

Unable to start SQL Server Svc?

Blocking and Deadlock :

====================

Deadlock :

What happens when MASTER DB is down?

What happens when MODEL DB is down?

Reach us on any help and support (Job & Interview) on SQL Server (On-premise &Azure)
Rajasekhar Reddy Bolla WhatsApp: +91 9966246368
(find me in LinkedIn & YouTube)

What happens when MSDB DB is down?

T_log File is growing, why?

What are the steps to Shrink T_log file?

Performance :

============

How to troubleshooting High CPU?

What is CXPACKETS ?

High memory :

===========

Min server memory :

• installation of SQL 2016 – 2017


• What is a checkpoint?
LDF committed to MDF

MDF =

LDF =

• What is page and extent?

• GAM/SGAM page?
[

• What is extent?

• What is Log Shipping.

• AlwaysOn

• What are the system database in SQL Sever

• Resource Database.

Reach us on any help and support (Job & Interview) on SQL Server (On-premise &Azure)
Rajasekhar Reddy Bolla WhatsApp: +91 9966246368
(find me in LinkedIn & YouTube)

• What is the use of TempDB database?

New 56Th batch on: 17th Jan 2022(Monday) | 2 weeks | Daily 2 hours | Monday to Saturday 7.30 AM
to 9.30 AM IST | WhatsApp me +91-9966246368
Demo video: https://youtu.be/4FNsoL0fueo

Course content: https://lnkd.in/gvmEb26

Trainer LinkedIn profile: https://lnkd.in/eA3kvsm

My YouTube Channel: https://lnkd.in/gBdiH_Q (subscribe)

Reach us on any help and support (Job & Interview) on SQL Server (On-premise &Azure)

You might also like