SQL Interview Preparation Guide
Hi, I’m Sonu Kumar Jha. I’ve been working with the MERN stack, building full-stack web
applications using MongoDB, Express, React, and [Link]. Recently, I started exploring .NET and
SQL to gain experience in enterprise technologies and backend frameworks used in large-scale
systems. I’ve also built small CRUD API projects using [Link] Core and SQL Server. This guide
covers key SQL concepts and questions I’ve prepared for my .NET Developer interview.
SQL Interview Questions & Answers
1. What is SQL?
SQL (Structured Query Language) is used to store, manage, and retrieve data from relational
databases using commands like SELECT, INSERT, UPDATE, and DELETE.
2. What are the different types of SQL statements?
DDL (CREATE, ALTER, DROP), DML (SELECT, INSERT, UPDATE, DELETE), DCL (GRANT,
REVOKE), TCL (COMMIT, ROLLBACK, SAVEPOINT).
3. What are Joins in SQL?
Joins combine rows from two or more tables based on a related column. Types: INNER, LEFT,
RIGHT, FULL, CROSS JOIN.
4. What are Triggers in SQL?
Triggers are special stored procedures that execute automatically when an event (INSERT,
UPDATE, DELETE) occurs in a table.
5. What is a Stored Procedure?
A stored procedure is a precompiled SQL program stored in the database that can be executed
multiple times for efficiency.
6. What is a View in SQL?
A View is a virtual table that displays data from one or more tables without storing it physically.
7. Difference between WHERE and HAVING?
WHERE filters rows before aggregation; HAVING filters results after aggregation (used with
GROUP BY).
8. What is Normalization?
Normalization organizes data to reduce redundancy and improve integrity. Normal forms: 1NF,
2NF, 3NF.
9. What is a Primary Key and Foreign Key?
Primary Key uniquely identifies a record. Foreign Key links tables and maintains referential integrity.
10. What is an Index?
An Index speeds up data retrieval but can slow down insert or update operations.
11. Difference between DELETE, TRUNCATE, and DROP?
DELETE removes specific rows, TRUNCATE removes all rows (cannot rollback), DROP deletes the
entire table.
12. What are Constraints?
Constraints ensure data integrity. Examples: PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
DEFAULT, NOT NULL.
13. Difference between UNION and UNION ALL?
UNION combines results and removes duplicates, UNION ALL keeps duplicates.
14. What is a Cursor?
A Cursor allows row-by-row processing of query results, often used for complex logic.
15. What is a Subquery?
A Subquery is a query inside another query used for filtering or calculation.
16. Difference between INNER JOIN and OUTER JOIN?
INNER JOIN returns matching rows, OUTER JOIN returns matching plus unmatched rows from one
or both tables.
17. What is an Aggregate Function?
Aggregate functions perform calculations on sets of data: COUNT(), SUM(), AVG(), MAX(), MIN().
18. What is a Transaction?
A Transaction is a group of operations executed as one unit following ACID properties.
19. What are ACID properties?
Atomicity, Consistency, Isolation, Durability — they ensure reliable database transactions.
20. Difference between Function and Stored Procedure?
Functions return a single value and can be used in SELECT. Procedures may or may not return
values and support transactions.