EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Software Development Software Development Tutorials Top Interview Question MS SQL Interview Questions
 

MS SQL Interview Questions

Priya Pedamkar
Article byPriya Pedamkar

Updated March 17, 2023

MS SQL Interview Questions

 

 

Introduction to MS SQL Interview Questions

If you are looking for a job related to MS SQL, you need to prepare for the 2022 MS SQL Interview Questions. Every interview is indeed different as per the different job profiles. Here, we have prepared the important MS SQL Interview Questions and Answers, which will help you succeed in your interview. This 2023 MS SQL Interview Questions article will present the 10 most important and frequently asked MS SQL interview questions. These interview questions are divided into two parts as follows:

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Part 1 – MS SQL Interview Questions (Basic)

This first part covers basic Interview Questions and Answers:

Q1. What is SQL? Describe the importance of SQL in RDBMS?

Answer:

SQL is a Structured Query Language. SQL is used to communicate with the database. SQL is the heart of RDBMS (Relational Database Management System). It is the language used to perform all the operations in a relational database. When you issue a command to the RDBMS in SQL, the RDBMS interprets your command and takes necessary actions.

Q2. What is the difference between SQL and PL/SQL?

Answer:

SQL PL/SQL
It is a Structured Query Language. It is Procedural language, an extension of SQL.
In SQL, you can execute a single command at a time. In pl/SQL, you can execute multiple lines of code at a time.
In SQL, commands are executed using DDL (Data Definition Language), DML (Data Manipulation Language). In pl/SQL, you can write multiple code lines that have procedure, function, packages, etc.
SQL commands can be used in pl/SQL. Pl/SQL cannot use in SQL.
An example of SQL is:

Select * from Table_name where condition

An example of pl/SQL is:

BEGIN
dbms_output.put_line (‘HELLO EDUCBA WORLD’);
END;
/

Q3. What are the main components of SQL?

Answer:

The main components of SQL are DDL, DML, DCL (Data Control Language), TCL (Transaction Control Language).

Data Definition Language: Tables are the only way to store data; all the information has to be arranged in the form of tables. Suppose you want to store some information (Name, city) about the company in the database. To store this, you need to create a table; you can create a table using the table command.

Code:

Create table company (name char (10), city char (10));

Using DDL, you can also alter or drop objects.

Data Manipulation Language: DML, as the name suggests, allows you to manipulate data in an existing table. You can do many operations using DML, such as insertion, updating, deletion, on a table.

  • Adding a row to a table

Code:

Insert into company values (‘XYZ’, ‘Sydney’);

  • Updating data in a table

Code:

Update company set city = ‘Melbourne’ where name = ‘XYZ’

Data Control Language:

  • DCL: This allows you to control access to the data.
  • Grant: Grants permission to one or more users to operate.
  • Revoke: Withdraw the access permission given by the grant statement.

Transaction Control Language: TCL includes commit, rollback, and save point to data.

Q4. What is the difference between delete and truncate commands?

Answer:

  • DELETE command can be used to delete rows from the particular table, and the WHERE clause can be used for condition. Commit, and Rollback functions can be performed on the delete command after the delete statement.
  • TRUNCATE is used to removes all rows from the table. When Truncate operation is used, it cannot be rolled back.

Q5. Write a SQL query to find the 3rd highest salary from the table without using the TOP/limit keyword?

Answer:

Select salary from EDUCBA_Employee E1 WHERE 2 = (Select count (Distinct (E2. salary))
from EDUCBA_EMPLOYEE E2 where E2. salary > E1. salary

Q6. How will you perform pattern matching operations in SQL?

Answer: 

LIKE operator is used for pattern matching, and it can be used in two ways -.

  • %: It Matches zero or more characters.

Code:

Select * from employee where name like ‘X%’

  • _(Underscore): It Matches exactly one character.

Code:

Select * from employee where name like ‘XY_’

Q7. Write a query to get employee names ending with a vowel?

Answer:

Code:

Select EMP_ID, EMP_NAME from EDUCBA_EMPLOYEE where EMP_NAME like '%[aeiou]'

Q8. How will you copy rows from one table to another table?

Answer:

The INSERT command will be used to adding up a row to a table by copying from another table. In this case, a subquery is used in place of the VALUES clause.

Part 2 – MS SQL Interview Questions (Advanced)

Let us now have a look at the advanced Interview Questions and Answers.

Q9. What is the difference between the ‘WHERE’ clause and the ‘HAVING’ clause?

Answer:

HAVING clause can only be used with the SELECT statement. HAVING clause is used with the GROUP BY clause, and if the GROUP BY clause is not used, then the HAVING clause behaves like a WHERE clause.HAVING Clause is only used with the GROUP BY command, whereas WHERE Clause is applied to each row after FROM clause and before they are going to a part of GROUP BY function in a query.

Q10. How will you get a first name, salary, and round the salary to thousands?

Answer:

Code:

SELECT FIRST_NAME, SALARY, ROUND (SALARY, -3) FROM EDUCBA_EMPLOYEE;

Q11. Display the first name and experience of the employees?

Answer:

Code:

SELECT FIRST_NAME, HIRE_DATE, FLOOR((SYSDATE-HIRE_DATE)/365) FROM EDUCBA_EMPLOYEE;

Q12. Write a query to get the first name and last name after converting the first letter of each name to upper case and the rest to lower case?

Answer:

Code:

SELECT INITCAP(FIRST_NAME), INITCAP(LAST_NAME) FROM EDUCBA_EMPLOYEE;

Q13. Display the length of the first name for employees where the last name contain the character ‘b’ after the 3rd position?

Answer:

Code:

SELECT FIRST_NAME, LAST_NAME FROM EDUCBA_EMPLOYEE WHERE INSTR(LAST_NAME,'B') > 3;

Q14. Change the salary of employee 115 to 8000 if the existing salary is less than 6000?

Answer:

Code:

UPDATE EDUCBA_EMPLOYEE SET SALARY = 8000 WHERE EMPLOYEE_ID = 115 AND SALARY < 6000;

Q15. How will you Insert a new employee into employees with all the required details?

Answer:

Code:

INSERT INTO EDUCBA_EMPLOYEE (EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, SALARY) VALUES (207, 'ANGELA', 'SNYDER','ANGELA','215 253 4737’, 12000);

Q16. Display employees who joined in the month of May?

Answer:

Code:

SELECT * FROM EDUCBA_EMPLOYEE WHERE TO_CHAR (HIRE_DATE, 'MON’) = 'MAY';

Q17. What is the meaning of “TRIGGER” in SQL?

Answer:

A trigger allows you to execute SQL query when an operation like insert, update, or delete commands are executed against a specific table.

Recommended Article

This has been a guide to a List Of MS SQL Interview Questions and Answers so that the candidate can crack down on these MS SQL Interview Questions easily. You may also look at the following articles to learn more –

  1. Top 12 SQL Interview Questions
  2. NoSQL Interview Questions
  3. Cloud Computing Interview Questions
  4. Manual Testing Interview Questions

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW