SQL Server Interview Questions


Q#1. What is SQL Server?

Ans. SQL Server is the RDBMS system provided by Microsoft which functions mainly as retrieving and storing the data as per user request. Sometimes it is mistakenly referred as SQL, but both are different, as SQL is a language whereas SQL Server is a Microsoft product that supports SQL.


Q#2. What are the different subsets of SQL?

Ans. DDL (Data Definition Language) – It allows you to perform various operations on the database such as CREATE, ALTER and DELETE objects. DML ( Data Manipulation Language) – It allows you to access and manipulate data. It helps you to insert, update, delete and retrieve data from the database. DCL ( Data Control Language) – It allows you to control access to the database. Example – Grant, Revoke access permissions.


Q# 3. What is the difference between clustered and a non-clustered index?

Ans. A clustered index is an index that rearranges the table in the order of index itself. Its leaf nodes contain data pages. A table can have only one clustered index. A non-clustered index is an index that does not re-arranges the table in the order of index itself. Its leaf nodes contain index rows instead of data pages. A table can have many non-clustered indexes.


Q#4. What is PL/SQL?

Ans. PL/SQL (Procedural Language for SQL) is a procedural language developed by Oracle to work with Oracle database using procedures in SQL. PL/SQL program units are compiled by the Oracle Database server and stored inside the database. And at run-time, both PL/SQL and SQL run within the same server process, bringing optimal efficiency. PL/SQL automatically inherits the robustness, security, and portability of the Oracle Database. PL/SQL syntaxes includes declarations for variables, constants, procedures, functions, conditions and loops.


Q#5. What is the recovery model? List the types of recovery model available in SQL Server?

Ans. Recovery model basically tells SQL Server what data should be kept in the transaction log file and for how long. A database can have only one recovery model. It also tells SQL server that which backup is possible in a particular recovery model selected. There are three types of recovery model: Full Simple Bulk-Logged


Q#6. What do you mean by table and field in SQL?

Ans. A table refers to a collection of data in an organised manner in form of rows and columns. A field refers to the number of columns in a table.


Q#7. What is RDBMS?

Ans. RDBMS or Relational Data Base Management Systems are database management systems that maintain data in the form of tables. We can create relationships between the tables. An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage.


Q#8. What is a database table?

Ans. Database table: Table contains records in the form of rows and columns. A permanent table is created in the database you specify and remains in the database permanently, until you delete it.


Q# 9. What's the difference between a primary key and a unique key?

Ans. The differences between the primary key and a unique key are: The primary key is a column whose values uniquely identify every row in a table. Primary key values can never be reused. They create a clustered index on the column and cannot be null. A Unique key is a column whose values also uniquely identify every row in a table but they create a non-clustered index by default and it allows one NULL only.


Q# 10. What are joins in SQL?

A JOIN clause is used to combine rows from two or more tables, based on a related column between them. It is used to merge two tables or retrieve data from there. There are 4 joins in SQL namely: Inner Join Right Join Left Join Full Join