EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials Top Interview Question MS SQL Interview Questions
Secondary Sidebar
Top Interview Question Tutorial
  • Interview Questions
    • Apache PIG Interview Questions
    • Elasticsearch Interview Questions
    • Data Engineer Interview Questions
    • Algorithm Interview Questions
    • OBIEE Interview Question
    • SSIS Interview Questions
    • Cognos Interview Questions
    • MapReduce Interview Questions
    • NoSQL Interview Questions
    • SharePoint Interview Questions
    • Sqoop Interview Questions
    • Business Intelligence Interview Questions
    • Mainframe Interview Questions
    • Rail Interview Questions
    • SSRS Interview Questions
    • Data Modeling Interview Questions
    • J2EE Interview Questions
    • Minitab Interview Questions
    • Statistics Interview Questions
    • MS SQL Interview Questions
    • Ab Initio Interview Questions
    • Spark Interview Questions
    • WordPress Interview Questions
    • OS Interview Questions
    • Drupal Interview Questions
    • OOP Interview Questions
    • Mulesoft Interview Questions
    • Typescript Interview Questions
    • Redux Interview Questions
    • Pig Interview Questions
    • ES6 Interview Questions
    • Multithreading Interview Questions
    • Go Interview Questions
    • APEX Interview Questions
    • Teradata Interview Questions
    • Groovy Interview Questions
    • ExtJS Interview Questions
    • E-Commerce Interview Questions
    • Appium Interview Questions
    • SOA Interview Questions
    • ITIL Interview Questions
    • Digital Electronics Interview Questions
    • IT Interview Questions
    • WinForms Interview Questions
    • IT Security Interview Questions
    • WCF Interview Questions
    • Microprocessor Interview Questions
    • Apache Interview Questions
    • MicroStrategy Interview Questions
    • Virtualization Interview Questions
    • UI Developer Interview Questions
    • Electrical Engineering Interview Questions
    • RMAN Interview Questions
    • SVN Interview Questions
    • Talend interview questions
    • SAP ABAP Interview Questions
    • Inheritance Interview Questions
    • Threading Interview Questions
    • Quality Control Interview Questions
    • Embedded System Interview Questions
    • OpenStack Interview Questions
    • Objective C Interview Questions
    • QA Interview Question
    • PLC Interview Questions
    • SDET Interview Questions
    • JCL Interview Questions
    • SOAP Interview Questions
    • IELTS Interview Questions
    • SoapUI Interview Questions
    • Front end Developer Interview Questions
    • DB2 Interview Questions
    • VSAM Interview Question
    • MVC Interview Questions
    • WPF Interview Questions
    • Java Collections Interview Questions
    • UI Designer Interview Questions
    • NLP Interview Questions
    • TFS Interview Questions
    • Active Directory Interview Questions
    • Xamarin Interview Questions
    • Intrusion Prevention System Interview Questions
    • COBOL Interview Questions
    • Control System Interview Questions
    • Blue Prism Interview Questions
    • Scenario Interview Questions
    • Unit testing interview questions
    • Linked List Interview Questions
    • Mainframe testing interview questions
    • Selenium Interview Questions
    • Binary Tree Interview Questions
    • Cloud Security Interview Questions
    • Functional Testing Interview Questions
    • Civil Engineering Questions for Interview
    • DHCP interview questions
    • Spring Batch Interview Questions
    • Perl interview questions
    • ESL interview questions
    • OBIEE Interview Questions
    • DynamoDB interview questions
    • Automation Anywhere Interview Questions
    • Scrum Interview Questions
    • Security Testing Interview Questions
    • Struts Interview Questions
    • Databricks Interview Questions
    • Electronics Engineering Interview Questions
    • Java concurrency interview questions
    • RxJava Interview Questions
    • ServiceNow Interview Question
    • XML Interview Questions
    • Entity Framework Interview Questions
    • Terraform Interview Questions
    • LINQ Interview Questions
    • MVVM Interview Questions
    • OSPF Interview Questions
    • Server interview questions
    • Appdynamics Interview Questions
    • Webpack Interview Questions
    • Data Architect Interview Questions
    • GitHub Interview Questions
    • Data Analyst Technical Interview Questions
    • GitHub JavaScript Interview Questions
    • Bitbucket Interview Questions
    • OOPs Java Interview Questions
    • DNS Interview Question
    • MPLS Interview Questions
    • Django Interview Question

Related Courses

Programming Languages Course

C programming Course

Selenium Training Certification

MS SQL Interview Questions

By Priya PedamkarPriya Pedamkar

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:

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.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

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’);

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,883 ratings)
  • 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
Popular Course in this category
MS SQL Training (16 Courses, 11+ Projects)
  16 Online Courses |  11 Hands-on Projects |  70+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

Programming Languages Training (41 Courses, 13+ Projects, 4 Quizzes)4.9
C Programming Training (3 Courses, 5 Project)4.8
Selenium Automation Testing Training (11 Courses, 4+ Projects, 4 Quizzes)4.7
3 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

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

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

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

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

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

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

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

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more