SQL Server Interview Questions

  • Share this blog:

Welcome to our SQL Server Interview Questions Blog! Structured Query Language (SQL) is a standard language for managing relational databases. SQL Server, developed by Microsoft, is one of the most widely-used database management systems in the world. With its robust features and capabilities, SQL Server is a preferred choice for many organizations.

If you are preparing for an SQL Server Interview or looking to enhance your skills in this domain, this blog is the perfect resource for you. Here, we have compiled a list of frequently asked SQL Server Interview Questions along with their detailed answers, which will help you gain a deeper understanding of this tool and its applications.

Whether you are a beginner or an experienced professional, these questions will provide you with a comprehensive overview of SQL Server and its functionalities, enabling you to crack your interview with confidence. So, without further ado, let's dive into the world of SQL Server and learn everything you need to know to excel in your career!

These SQL Server Interview Questions are divided into two categories

Most frequently asked SQL Server Interview Questions

SQL Server Interview Questions for Freshers

Q1) What is SQL or Structured Query Language? 

Ans: SQL is a language that is used to communicate with the database and this language supports operations like insertion, update, retrieval, and deletion.

Q2) Which TCP/IP port does SQL Server run on? How can it be changed?

Ans: SQL Server runs on port 1433. It can be changed from the Network Utility TCP/IP properties.

Q3) How can SQL Server instances be hidden?

Ans: To hide a SQL Server instance, we need to make a change in SQL Server Configuration Manager. To do this launch SQL Server Configuration Manager and do the following: select the instance of SQL Server, right-click, and select Properties. After selecting properties you will just set Hide Instance to “Yes” and click OK or Apply. After the change is made, you need to restart the instance of SQL Server to not expose the name of the instance.

Q4) What is the difference between clustered and non-clustered indexes?

Ans: A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore the table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.

A non-clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on the disk. The leaf node of a non-clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.

Q5) What are the new error-handling commands introduced with SQL Server 2005 and beyond? What command did they replace? How are the new commands used?

Ans: The new commands are to TRY and CATCH.

Although they do not directly replace any specific command, in many respects the TRY and CATCH have been used over the RAISERROR command.

The TRY block is for the business logic and the CATCH logic is for capturing the error.

Q6) What different steps will a SQL Server Developer take to secure SQL Server?


  • Preferring NT authentication
  • Using server, database, and application roles to control access to the data
  • Securing the physical database files using NTFS permissions
  • Using an unusable SA password, restricting physical access to the SQL Server
  • Renaming the Administrator account on the SQL Server computer
  • Disabling the Guest account, enabling auditing using multiprotocol encryption
  • Setting up SSL, setting up firewalls, isolating SQL Server from the webserver

Q7) What's the difference between a primary key and a unique key?

Ans: Both the primary key and unique key enforce the uniqueness of the column on which they are defined. But by default, the primary key creates a clustered index on the column, whereas the unique one creates a nonclustered index by default. Another major difference is that the primary key doesn't allow NULLs, but the unique key allows one NULL only.

If you want to enrich your career and become a professional in SQL Server, then visit Tekslate - a global online training platform: "SQL Server Training" This course will help you to achieve excellence in this domain.


Q8) Explain the properties of a relational table.

Ans: Below is the list of properties the relational table should have

  • Column value of any kind.
  • The insignificant sequence of columns.
  • The insignificant sequence of rows.
  • Unique name for each column.
  • Atomic values.

Q9) What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?

Ans: They specify a search condition for a group or an aggregate. But the difference is that HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause. Having Clause is basically used only with the GROUP BY function in a query whereas WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.

Q10) What are the three ways that Dynamic SQL can be issued?


  • Writing a query with parameters.
  • Using EXEC.
  • Using sp_executesql.

Q11) What is ACID mean in SQL Server?

Ans: ACID is used for evaluating application and database architecture. Below are the ACID properties –

  • Atomicity
  • Consistency
  • Isolation
  • Durability

Q12) Explain the primary key in SQL Server.

Ans: This is the combination of fields/columns which are used to uniquely specify a row. The primary key has a unique constraint defined on the column and the value in the column cannot be NULL.

Q13) What are the different index configurations a table can have?

Ans: A table can have one of the following index configurations:

  • No indexes
  • A clustered index
  • A clustered index and many nonclustered indexes
  • A nonclustered index
  • Many nonclustered indexes

Q14) What is SQL Profiler?

Ans: SQL Profiler is a graphical tool that allows system administrators to monitor events in an instance of Microsoft SQL Server. You can capture and save data about each event to a file or SQL Server table to analyze later. For example, you can monitor a production environment to see which stored procedures are hampering performance by executing too slowly.

Use SQL Profiler to monitor only the events in which you are interested. If traces are becoming too large, you can filter them based on the information you want, so that only a subset of the event data is collected. Monitoring too many events adds overhead to the server and the monitoring process and can cause the trace file or trace table to grow very large, especially when the monitoring process takes place over a long period of time.

Q15) What is the native system stored procedure to issue a command against all databases?

Ans: The sp_MSforeachdb system stored procedure accepts the @Command parameter which can be issued against all databases. The '?' is used as a placeholder for the database name to issue the same command.

The alternative is to use a cursor to process specific commands against each database.

Checkout Our Latest Blog on SQL Server Integration

SQL Server Interview Questions for Experienced

Q16) What are Hotfixes and Patches?

Ans: Hotfixes are software patches that were applied to live systems (the ones still running.) A hotfix is a single, cumulative package that includes one or more files used to address a problem in a software product (i.e. a software bug).

In the Microsoft SQL SERVER context, hotfixes are small patches designed to address specific issues, most commonly to freshly-discovered security holes.

Q17) What are the different types of locks available in SQL Server?

Ans: list of locks available in SQL Server –

  • Update Locks
  • Shared Locks
  • Exclusive Locks

Q18) What are the different types of Collation Sensitivity?


  • Case sensitivity - A and a, B and b, etc.
  • Accent sensitivity
  • Kana Sensitivity - When Japanese kana characters Hiragana and Katakana are treated differently, it is called Kana sensitive.
  • Width sensitivity - A single-byte character (half-width) and the same character represented as a double-byte character (full-width) are treated differently than it is width sensitive.

Q19) What is OLTP (Online Transaction Processing)?

Ans: In OLTP - online transaction processing systems relational database design uses the discipline of data modeling and generally follows the Codd rules of data normalization in order to ensure absolute data integrity. Using these rules complex information is broken down into its most simple structures (a table) where all of the individual atomic level elements relate to each other and satisfy the normalization rules.

Q20) In SQL Server 2005, what new functionality was introduced with the GO command?

Ans: The ability to issue a batch 'N number of times' based on the value following the GO command.

In some respects, this functionality replaces using a WHILE loop.

Q21) When is the use of the UPDATE_STATISTICS command?

Ans: This command is basically used when a large processing of data has occurred. If a large number of deletions any modification or Bulk Copy into the tables has occurred, it has to update the indexes to take these changes into account. UPDATE_STATISTICS updates the indexes on these tables accordingly.

Checkout Blog on SQL Server Database Setup in Informatica

Q22) What is the SQL Server Agent?

Ans: SQL Server agent plays an important role in the day-to-day tasks of a database administrator (DBA). It is often overlooked as one of the main tools for SQL Server management. Its purpose is to ease the implementation of tasks for the DBA, with its full-function scheduling engine, which allows you to schedule your own jobs and scripts.

Q23) Name 3 ways to get an accurate count of the number of records in a table?

Ans: SELECT * FROM table1 SELECT COUNT(*) FROM table1 SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1) AND did < 2

Q24) What is the STUFF function and how does it differ from the REPLACE function?

Ans: The STUFF function is used to overwrite existing characters. Using this syntax, STUFF (string_expression, start, length, replacement_characters), string_expression is the string that will have characters substituted, a start is a starting position, the length is the number of characters in the string that are substituted, and replacement_characters are the new characters interjected into the string. REPLACE function to replace existing characters of all occurrences. Using the syntax REPLACE (string_expression, search_string, replacement_string), where every incidence of search_string found in the string_expression will be replaced with replacement_string.

Q25) Explain foreign key in SQL Server.

Ans: Foreign key is used to establish a relationship between the columns of other tables. The foreign key relationship is to be created between two tables by referencing a column of the table to the primary key of another table.

Q26) What are the advantages and disadvantages of stored procedures in SQL Server?



  • Testing
  • Maintainability
  • Speed
  • Optimization
  • Security etc.


  • Portability
  • Limited Coding functionality

Q27) Explain SQL server authentication modes.

Ans: The two authentication modes of SQL server –

  • Mixed Mode
  • Windows Mode

You liked the article?

Like : 1

Vote for difficulty

Current difficulty (Avg): Medium

About Author
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.