SQL Query Interview Questions and Answers
SQL Query in SQL Server interview questionsThese SQL Query in SQL Server questions have been designed for various interviews, competitive exams and entrance tests. We have covered questions on both basic and advanced concepts which will help you improve your skills to face interview questions on SQL Query.
Who are these SQL Query interview questions designed for?All the experienced programmer, database administrator, database developers, DBA, tester, web developers, application developers, programmers and software engineer will find these questions extremely useful. All freshers, BCA, BE, BTech, MCA and college students wanting to make a career in front end designing will be highly benefited by these questions.
SQL Query interview questions topicsThis section covers SQL Query in SQL Server topics like - RDBMS Concepts, Data Types, Operators, Create Database,Drop Database,Select Database,Create Table, Drop Table, Order By, Group By, Constraints, Joins, Unions, Indexes, Views, Date Functions etc.
SQL Query interview questions and answers are based on following tables: Employee, Department and Incentives
1. Write a SQL query to get random employee record from the table.
select top 1 * from employee order by newid()
2. Write a SQL query to select first 2 characters of EmpName from employee table.
select substring(EmpName,1,2) from employee
3. Write a SQL query to get length of EmpName from employee table.
select len(EmpName) from employee
4. Write a SQL query get employee details from employee table whose employee name are "Neeraj" and "Naveen".
Select * from employee where EmpName in ('Neeraj','Naveen')
5. Can you select employee details from employee table whose name ends with 'h' and name contains 5 letters?
Select * from employee where EmpName like '_____n'
6. Write a SQL query to get position of 'a' in name 'Naveen' from employee table.
Select CHARINDEX('a',EmpName,0) from employee where EmpName='Naveen'
7. Select all EmpName after removing white spaces from right side.
select RTRIM(EmpName) from employee
8. Select names of employees who has '%' in EmpName.
Select EmpName from employee where EmpName like '%[%]%'