SQL Server Interview Questions

What is SQL or Structured Query Language?

SQL is a language which is used to communicate with the database and this language supports operations like insertion, updation, retrieval and deletion.

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

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

How can SQL Server instances be hidden?

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.

What are the difference between clustered and a non-clustered index?

A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore 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.

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?

The new commands are TRY and CATCH.

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

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

What different steps will a SQL Server Developer takes 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 web server

Interested in mastering SQL Server Training?
Enroll now for FREE demo on SQL Server Training.

What’s the difference between a primary key and a unique key?

Both primary key and unique key enforces 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, primary key doesn’t allow NULLs, but unique key allows one NULL only.

Explain the properties of a relational table?

Below are the list of properties relational table should have

Column value of any kind.

Insignificant sequence of columns.

Insignificant sequence of rows.

Unique name for each column.

Atomic values.

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

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.

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

Writing a query with parameters.

Using EXEC.

Using sp_executesql.

What is ACID mean in Sql Server?

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





Explain primary key in Sql Server?

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

What are the different index configurations a table can have?

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

What is SQL Profiler?

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.

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

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.

What are Hotfixes and Patches?

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

What are the different types of locks available in Sql Server?

list of locks available in Sql Server –

-Update Locks

-Shared Locks

-Exclusive Locks

What are 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.

What is OLTP (Online Transaction Processing)?

In OLTP – online transaction processing systems relational database design use the discipline of data modeling and generally follow 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.

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

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.

When is the use of UPDATE_STATISTICS command?

This command is basically used when a large processing of data has occurred. If a large amount 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.

What is SQL Server Agent?

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.

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

SELECT * FROM table1
SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1) AND indid < 2

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

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, start is the starting position, 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.

Explain foreign key in Sql Server?

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

What are the advantages and disadvantages of stored procedure in Sql Server?






Security etc.



Limited Coding functionality

Explain Sql server authentication modes?

The two authentication modes of sql server –

-Mixed Mode

-Windows Mode

Review Date
Reviewed Item
SQL Server Interview Questions
Author Rating

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on SQL Server Interview Questions"

    Leave a Message

    Your email address will not be published. Required fields are marked *


    Please leave a message and we'll get back to you soon.
    Three + 6