MS SQL Server Optimization Interview Preparation Guide

Optimize your SQL Server Optimization interview preparation with our curated set of 7 questions. These questions will test your expertise and readiness for any SQL Server Optimization interview scenario. Ideal for candidates of all levels, this collection is a must-have for your study plan. Access the free PDF to get all 7 questions and give yourself the best chance of acing your SQL Server Optimization interview. This resource is perfect for thorough preparation and confidence building.
Tweet Share WhatsApp

7 SQL Server Optimization Questions and Answers:

1 :: Explain Hostprotectionattribute in SQL server 2005?

It allows the use of declarative security actions to determine host protection requirements. This class cannot be inherited
Download PDFRead All SQL Server Optimization Questions

2 :: What is a deadlock and what is a live lock? How will you go about resolving deadlocks?

A deadlock can occur when two or more processes that strive to acquire resources are not able to acquire them due to some of the following reasons:

Two processes may be interdependent upon each other,

If there are more than 2 processes, then if a graph is plotted, then there could be a cycle,

A server maintains a graph. The processes acquiring the resources would intimate the server about their requirement. If the server detects an occurance of a deadlock, the user process is be terminated.

In a livelock, a request for an exclusive lock is denied repeatedly due to a series of overlapping shared locks that keep interfering.

An SQL Server detects this situation after four denials and then refuses further shared locks.

When a write transaction is forced to wait indefinitely due to read transactions that monopolize a table or a page then a live lock occurs.

3 :: What are the steps you will take, if you are tasked with securing an SQL Server?

Perform the following SQL checks after installing the Server:

Check if Administrators group belongs to sysadmin role
Check if CmdExec role is restricted to sysadmin only
Check if SQL Server is running on a Domain Controller
Check if sa account password is exposed
Check SQL installation folders access permissions
Check if Guest account has database access
Check if the Everyone group has access to SQL registry keys
Check if SQL service accounts are members of the local Administrators group
Check if SQL accounts have blank or simple passwords
Check for missing SQL hotfixes
Check the SQL Server authentication mode type
Check the number of sysadmin role members

Then, you should require Windows Authentication Mode for connections to SQL Server, whenever possible.

You should isolate your server and back it up regularly.

You should assign a strong sa password.

You should limit privilege level of SQL Server Services.

Configure your firewall to filter out packets addressed to TCP port 1433 and UDP port 1434. ports associated with named instances should also be blocked at the firewall.

You should Use a secure file system.

Old setup files should be Deleted or secured.

You should log failed connection attempts to SQL Server and review the log regularly.Enable auditing of failed connections with Enterprise Manager in SQL Server.

4 :: What is Shared lock?

Shared Lock allows simultaneous access of record by multiple Select statements.
Shared Lock blocks record from updating and will remain in queue waiting while record is accessed for reading.
If update process is going on then read command will have to wait until updating process finishes.

5 :: What is Update locks?

This lock is used with the resources to be updated.
Download PDFRead All SQL Server Optimization Questions

6 :: What is Exclusive locks?

This kind of lock is used with data modification operations like update, insert or delete.

7 :: What are the lock types?

Main lock types:

Shared: Applied to read only operations where the data is not modified. E.g.: Select statements.
Update: Applied to resources which can be updated. It resolves dead locks in case of multiple sessions are reading, locking or updating resources later.
Exclusive: Used for operations involving data modification. E.g.: Insert, Update, and Delete. This ensures that multiple updates are not made to the same data at the same time.
Intent: Establishes a lock hierarchy. E.g.: Intent shared Intent exclusive and Shared with intentexclusive.
Schema: Used when schema dependent operations are being executed. E.g.: Schema modification and Schema stability.
Bulk update: Used while bulk copying of data and Tablock is specified.