SQL Server Interview Questions

23 September, 2020


Related Blogs


1.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.

2.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.

3.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.

4.What is the difference between clustered and non-clustered index?

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 disk. The leaf node of a non clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.

5.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.

6.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

7.What's the difference between a primary key and a unique key?

Ans: Both primary key and unique key enforces the uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique 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.

8.Explain the properties of a relational table?

Ans: Below are the list of properties 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.

9.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.

10.What are the three ways that Dynamic SQL can be issued?


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

11.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

12.Explain 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.

13.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

Checkout Our  Frequently Asked SQL Server DBA Interview Questions and Answers

14.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 performances 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.

15.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.

16.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 Microsoft SQL SERVER context, hotfixes are small patches designed to address specific issues, most commonly to freshly-discovered security holes.

17.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

18.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.

19.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.

20.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.

21.When is the use of 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.

22.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.

23.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

24.What is the STUFF function and how does it differ from the REPLACE function?

Ans: 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 the 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.

25.Explain foreign key in SQL Server?

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

26.What are the advantages and disadvantages of stored procedures in SQL Server?

Ans: Advantages

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


  • Portability
  • Limited Coding functionality

27.Explain SQL server authentication modes?

Ans: The two authentication modes of SQL server –

  • Mixed Mode
  • Windows Mode
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 .