0% found this document useful (0 votes)
4 views

notes 1

Uploaded by

tushartyagi2905
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

notes 1

Uploaded by

tushartyagi2905
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

800+ SQL SERVER

INTERVIEW
QUESTION
ANSWERS PDF
www.interviewquestionspdf.com
SQL SERVER INTERVIEW QUESTION
ANSWERS PDF (MORE THAN 800+ QUESTION FREE PDF
DOWNLOAD)
BY Vikas Ahlawat (www.interviewquestionspdf.com)
For latest interview questions must visit www.interviewquestionspdf.com

SQL SERVER INTERVIEW QUESTIONS ANSWERS

Description Link
Basic SQL Interview Q.(for 0-1 year exp) Sql Server Basic Interview Query Set-1
String Related Basic Queries(for 0-1 year exp) Sql Server Basic Interview Query Set-2
Date Time related Queries(for 0-1 year exp) Sql Server Date-Time Interview Query SET-3
Salary Related Queries (for 0-2 year exp) Sql Server Salary Interview Query SET-4
Group By Related Queries(for 0-2 year exp) Sql Server Group By Interview Query SET-5
Join Related Queries(for 0-2 year exp) Sql Server Join Interview Query SET-6
Tricky Join Queries(for 0-2 year exp) Sql Server Tricky Join Interview Query SET-7
DDL Queries(for 0-2 year exp) Sql Server DDL Interview Query SET-8
Very Interesting set(for 2-5+ year exp) Small but tricky Interview Query SET-9
Very Much Tricky Q.(for 2-5+ year exp) Very much Tricky(not 4 freshers)Query SET-10

Complex Query(for 2-5+ year exp) Sql Server Complex Interview Query SET-11
Data type Interview Q.(for 2-5+ year exp) Sql Server Datatype Interview Questions 12
TCS Tricky Interview Q.(for 2-5+ year exp) TCS Sql Server Tricky Interview Queries 13
HCL SQL Interview Q.(for 3-5+ year exp) HCL Sql Server Interview Queries 14
View Interview Questions(for 2-5+ year exp) Sql Server View Interview Questions 15
Index Interview Questions(for 2-5+ year exp) Sql Server Index Interview Questions 16
Stored Proc. Interview Q.(for 2-5+ year exp) Sql Server SP Interview Questions 17
Temp Table Interview Q.(for 2-5+ year exp) Sql Server Temp Table Interview Questions 18
Sql S. 2016 Interview Q (for 2-5+ year exp) Sql Server 2016 Interview Questions 19
Constraints Interview Q. (for 2-5+ year exp) Sql Server Constraints Interview Questions 20
Storage Related Interview Q. (for 2-5+ year exp) Sql Server Storage/Size Interview Questions 21
Basic Sql Server Interview Q.(for 2-5+ year exp) Sql Server Very Basic Interview Questions 22
Sql Server 2017 Interview Q.(for 0-5+ year exp) Sql Server 2017 Interview Questions 23
300 SQL Interview Question(for 0-5+ year exp) Sql Server 300 Random Interview Questions 24
Here our step by step SQL Server Interview Questions/ TSQL Queries asked during
interview.

Set-1: Sql Server Basic Interview Query


Tables:-

1. Write a query to get all employee detail from "EmployeeDetail" table


ANS:
MS SQL Server: SELECT * FROM EmployeeDetail
Oracle: SELECT * FROM EmployeeDetail
MySQL: SELECT * FROM EmployeeDetail

2. Write a query to get only "FirstName" column from "EmployeeDetail" table


ANS:
MS SQL Server: SELECT FirstName FROM EmployeeDetail
Oracle: SELECT FirstName FROM EmployeeDetail
MySQL: SELECT FirstName FROM EmployeeDetail
3. Write a query to get FirstName in upper case as "First Name".
ANS:
MS SQL Server: SELECT UPPER(FirstName) AS [First Name] FROM EmployeeDetail
Oracle: SELECT UPPER(FirstName) AS [First Name] FROM EmployeeDetail
MySQL: SELECT UPPER(FirstName) AS [First Name] FROM EmployeeDetail

4. Write a query to get FirstName in lower case as "First Name".


ANS:
MS SQL Server: SELECT LOWER(FirstName) AS [First Name] FROM EmployeeDetail
Oracle: SELECT LOWER(FirstName) AS [First Name] FROM EmployeeDetail
MySQL: SELECT LOWER(FirstName) AS [First Name] FROM EmployeeDetail

5. Write a query for combine FirstName and LastName and display it as "Name" (also
include white space between first name & last name)
ANS:
MS SQL Server: SELECT FirstName +' '+ LastName AS [Name] FROM EmployeeDetail
Oracle: SELECT FirstName ||' '|| LastName AS [Name] FROM EmployeeDetail
MySQL: SELECT CONCAT(FirstName ,' ', LastName) AS [Name] FROM EmployeeDetail
6. Select employee detail whose name is "Vikas"
ANS:
MS SQL Server: SELECT * FROM EmployeeDetail WHERE FirstName = 'Vikas'
Oracle: SELECT * FROM EmployeeDetail WHERE FirstName = 'Vikas'
MySQL: SELECT * FROM EmployeeDetail WHERE FirstName = 'Vikas'

7. Get all employee detail from EmployeeDetail table whose "FirstName" start with
latter 'a'.
ANS:
MS SQL Server: SELECT * FROM EmployeeDetail WHERE FirstName like 'a%'
Oracle: SELECT * FROM EmployeeDetail WHERE FirstName like 'a%'
MySQL: SELECT * FROM EmployeeDetail WHERE FirstName like 'a%'

8. Get all employee details from EmployeeDetail table whose "FirstName" contains
'k'
ANS:
MS SQL Server: SELECT * FROM EmployeeDetail WHERE FirstName like '%k%'
Oracle: SELECT * FROM EmployeeDetail WHERE FirstName like '%k%'
MySQL: SELECT * FROM EmployeeDetail WHERE FirstName like '%k%'

9. Get all employee details from EmployeeDetail table whose "FirstName" end with
'h'
ANS:
MS SQL Server: SELECT * FROM EmployeeDetail WHERE FirstName like '%h'
Oracle: SELECT * FROM EmployeeDetail WHERE FirstName like '%h'
MySQL: SELECT * FROM EmployeeDetail WHERE FirstName like '%h'

10. Get all employee detail from EmployeeDetail table whose "FirstName" start with
any single character between 'a-p'
ANS:
MS SQL Server: SELECT * FROM EmployeeDetail WHERE FirstName like '[a-p]%'
Oracle: SELECT * FROM EmployeeDetail WHERE FirstName like '[a-p]%'
MySQL: SELECT * FROM EmployeeDetail WHERE FirstName like '[a-p]%'
Set-2: Sql Server Basic Interview Query
Related Tables:-

Questions Answers

11). Get all employee detail from EmployeeDetail table whose "FirstName" not start
with any single character between 'a-p'
Ans: SELECT * FROM [EmployeeDetail] WHERE FirstName like '[^a-p]%'

12). Get all employee detail from EmployeeDetail table whose "Gender" end with 'le'
and contain 4 letters. The Underscore(_) Wildcard Character represents any single
character.
Ans: SELECT * FROM [EmployeeDetail] WHERE Gender like '__le' --there are two "_"

13). Get all employee detail from EmployeeDetail table whose "FirstName" start with
'A' and contain 5 letters.
Ans: SELECT * FROM [EmployeeDetail] WHERE FirstName like 'A____' --there are four "_"

14). Get all employee detail from EmployeeDetail table whose "FirstName"
containing '%'. ex:-"Vik%as".
Ans: SELECT * FROM [EmployeeDetail] WHERE FirstName like '%[%]%'
--According to our table it would return 0 rows, because no name containg '%'

15). Get all unique "Department" from EmployeeDetail table.


Ans: SELECT DISTINCT(Department) FROM [EmployeeDetail]

16). Get the highest "Salary" from EmployeeDetail table.


Ans: SELECT MAX(Salary) FROM [EmployeeDetail]

17). Get the lowest "Salary" from EmployeeDetail table.


Ans: SELECT MIN(Salary) FROM [EmployeeDetail]

***SQL SERVER DATE RELATED INTERVIEW QUERY***

18). Show "JoiningDate" in "dd mmm yyyy" format, ex- "15 Feb 2013"
Ans: SELECT CONVERT(VARCHAR(20),JoiningDate,106) FROM [EmployeeDetail]

19). Show "JoiningDate" in "yyyy/mm/dd" format, ex- "2013/02/15"


Ans: SELECT CONVERT(VARCHAR(20),JoiningDate,111) FROM [EmployeeDetail]

20). Show only time part of the "JoiningDate".


Ans: SELECT CONVERT(VARCHAR(20),JoiningDate,108) FROM [EmployeeDetail]

You might also like