Post on 27-Feb-2018
7/25/2019 100 sql interview questions and answers
1/103
hirist.com
www.hirist.com
SQLTOP 100INTERVIEW QUESTIONS & ANSWERS
7/25/2019 100 sql interview questions and answers
2/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is DBMS?
2
QUESTION
A Database Management System (DBMS) is a program that controls creation, maintenance and use of a database.
DBMS can be termed as File Manager that manages data in a database rather than saving it in file systems.
ANSWER
QUESTION 1
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
3/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is RDBMS?
3
QUESTION
RDBMS stands for Relational Database Management System. RDBMS store the data into the collection of tables,
which is related by common fields between the columns of the table. It also provides relational operators tomanipulate the data stored into the tables.
Example: SQL Server.
ANSWER
QUESTION 2
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
4/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is SQL?
4
QUESTION
SQL stands for Structured Query Language , and it is used to communicate with the Database. This is a standard
language used to perform tasks such as retrieval, updation, insertion and deletion of data from a database.Standard SQL Commands are Select.
ANSWER
QUESTION 3
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
5/103For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is a Database?
5
QUESTION
Database is nothing but an organized form of data for easy access, storing, retrieval and managing of data. This is
also known as structured form of data which can be accessed in many ways.Example: School Management Database, Bank Management Database.
ANSWER
QUESTION 4
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
6/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What are tables and Fields?
6
QUESTION
A table is a set of data that are organized in a model with Columns and Rows. Columns can be categorized as
vertical, and Rows are horizontal. A table has specified number of column called fields but can have any numberof rows which is called record.
Example:.
Table: Employee.
Field: Emp ID, Emp Name, Date of Birth.
Data: 201456, David, 11/15/1960.
ANSWER
QUESTION 5
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
7/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is a primary key?
7
QUESTION
A primary key is a combination of fields which uniquely specify a row. This is a special kind of unique key, and it has
implicit NOT NULL constraint. It means, Primary key values cannot be NULL.
ANSWER
QUESTION 6
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
8/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is a unique key?
8
QUESTION
A Unique key constraint uniquely identified each record in the database. This provides uniqueness for the column or
set of columns.A Primary key constraint has automatic unique constraint defined on it. But not, in the case of Unique Key.
There can be many unique constraint defined per table, but only one Primary key constraint defined per table.
ANSWER
QUESTION 7
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
9/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is a foreign key?
9
QUESTION
A foreign key is one table which can be related to the primary key of another table. Relationship needs to be created
between two tables by referencing foreign key with the primary key of another table.
ANSWER
QUESTION 8
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
10/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What are the types of join and explain each?
10
QUESTION
There are various types of join which can be used to retrieve data and it depends on the relationship between
tables.
Inner Join:Inner join return rows when there is at least one match of rows between the tables.
Right Join:Right join return rows which are common between the tables and all rows of Right hand side table.
Simply, it returns all the rows from the right hand side table even though there are no matches in the left hand side
table.
Left Join:Left join return rows which are common between the tables and all rows of Left hand side table. Simply, it
returns all the rows from Left hand side table even though there are no matches in the Right hand side table.
Full Join:Full join return rows when there are matching rows in any one of the tables. This means, it returns all the
rows from the left hand side table and all the rows from the right hand side table.
ANSWER
QUESTION 9
h
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
11/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
Explain an outer join?
11
QUESTION
An outer join includes rows from tables when there are no matching values in the tables.
ANSWER
QUESTION 10
hi i
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
12/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is normalization?
12
QUESTION
Normalization is the process of minimizing redundancy and dependency by organizing fields and table of a
database. The main aim of Normalization is to add, delete or modify field that can be made in a single table.
ANSWER
QUESTION 11
hi i
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
13/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is Denormalization?
13
QUESTION
DeNormalization is a technique used to access the data from higher to lower normal forms of database. It is also
process of introducing redundancy into a table by incorporating data from the related tables.
ANSWER
QUESTION 12
hi i t
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
14/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What are all the different normalizations?
14
QUESTION
The normal forms can be divided into 4 forms, and they are explained below -.
First Normal Form (1NF):This should remove all the duplicate columns from the table. Creation of tables for therelated data and identification of unique columns.
Second Normal Form (2NF):Meeting all requirements of the first normal form. Placing the subsets of data in
separate tables and Creation of relationships between the tables using primary keys.
Third Normal Form (3NF): This should meet all requirements of 2NF. Removing the columns which are not
dependent on primary key constraints.
Fourth Normal Form (4NF): Meeting all the requirements of third normal form and it should not have multi-
valued dependencies.
ANSWER
QUESTION 13
hi i t
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
15/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is an Index? What are all the different types of indexes?
15
QUESTION
An index is performance tuning method of allowing faster retrieval of records from the table. An index creates an
entry for each value and it will be faster to retrieve data.
This indexing does not allow the field to have duplicate values if the column is unique indexed. Unique index can be
applied automatically when primary key is defined.
Clustered Index:This type of index reorders the physical order of the table and search based on the key values.
Each table can have only one clustered index.
Non Clustered Index:Non Clustered Index does not alter the physical order of the table and maintains logical
order of data. Each table can have 999 non clustered indexes.
ANSWER
QUESTION 14
hi i t
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
16/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is a relationship and what are they?
16
QUESTION
Database Relationship is defined as the connection between the tables in a database. There are various data
basing relationships, and they are as follows:.
One to One Relationship.
One to Many Relationship.
Many to One Relationship.
Self-Referencing Relationship.
ANSWER
QUESTION 15
hirist
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
17/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is a query?
17
QUESTION
A DB query is a code written in order to get the information back from the database. Query can be designed in such
a way that it matched with our expectation of the result set. Simply, a question to the Database.
ANSWER
QUESTION 16
hirist
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
18/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is subquery? What are the types of subquery?
18
QUESTION
A subquery is a query within another query. The outer query is called as main query, and inner query is called
subquery. SubQuery is always executed first, and the result of subquery is passed on to the main query.
There are two types of subqueryCorrelated and Non-Correlated.
A correlated subquery cannot be considered as independent query, but it can refer the column in a table listed in the
FROM the list of the main query.
A Non-Correlated sub query can be considered as independent query and the output of subquery are substituted in
the main query.
ANSWER
QUESTION 17
hirist
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
19/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is a trigger?
19
QUESTION
A DB trigger is a code or programs that automatically execute with response to some event on a table or view in a
database. Mainly, trigger helps to maintain the integrity of the database.
Example: When a new student is added to the student database, new records should be created in the related
tables like Exam, Score and Attendance tables.
ANSWER
QUESTION 18
hirist
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
20/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What are the types of Triggers?
20
QUESTION
There are four types of triggers and they are:
Insert Delete
Update
Instead of
ANSWER
QUESTION 19
hirist
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
21/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is the difference between DELETE TRUNCATE and DROP commands?
21
QUESTION
DELETE command is used to remove rows from the table, and WHERE clause can be used for conditional set of
parameters. Commit and Rollback can be performed after delete statement.
TRUNCATE removes all rows from the table. Truncate operation cannot be rolled back.
Drop command is used to drop the table or keys like primary, foreign from a table.
ANSWER
QUESTION 20
hirist QUESTION
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
22/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is data Integrity?
22
QUESTION
Data Integrity defines the accuracy and consistency of data stored in a database. It can also define integrity
constraints to enforce business rules on the data when it is entered into the application or database.
ANSWER
QUESTION 21
hirist QUESTION
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
23/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is collation?
23
QUESTION
Collation is defined as set of rules that determine how character data can be sorted and compared. This can be
used to compareA and, other language characters and also depends on the width of the characters.
ASCII value can be used to compare these character data.
ANSWER
QUESTION 22
hirist QUESTION 23
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
24/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
Advantages and Disadvantages of Stored Procedure?
24
QUESTION
Stored procedure can be used as a modular programming means create once, store and call for several times
whenever required. This supports faster execution instead of executing multiple queries. This reduces network
traffic and provides better security to the data.
Disadvantage is that it can be executed only in the Database and utilizes more memory in the database server.
ANSWER
QUESTION 23
hirist QUESTION 24
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
25/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is SQL Injection ?
25
QUESTION
SQL Injection is one of the techniques uses by hackers to hack a website by injecting SQL commands in data fields.
ANSWER
QUESTION 24
hirist QUESTION 25
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
26/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
26
QUESTION
They specify a search condition for a group or an aggregate. But the difference is that HAVING can be used only
with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used,
HAVING behaves like a WHERE clause. Having Clause is basically used only with the GROUP BY function in a
query whereas WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.
ANSWER
QUESTION 25
hirist QUESTION 26
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
27/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
How would apply date range filter?
27
QUESTION
a.You can use simple condition >= and
7/25/2019 100 sql interview questions and answers
28/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is the difference between JOIN and UNION?
28
QUESTION
SQL JOIN allows us to lookup records on other table based on the given conditions between two tables. For
example, if we have the department ID of each employee, then we can use this department ID of the employee
table to join with the department ID of department table to lookup department names.
UNION operation allows us to add 2 similar data sets to create resulting data set that contains all the data from the
source data sets. Union does not require any condition for joining. For example, if you have 2 employee tables
with same structure, you can UNION them to create one result set that will contain all the employees from both of
the tables.
SELECT * FROM EMP1
UNION
SELECT * FROM EMP2;
ANSWER
QUESTION 27
hirist QUESTION 28
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
29/103
For the hottest SQL jobs, please visit www.hirist.com
hirist.com
What is the difference among UNION, MINUS and INTERSECT?
29
QUESTION
UNION combines the results from 2 tables and eliminates duplicate records from the result set.
MINUS operator when used between 2 tables, gives us all the rows from the first table except the rows which are
present in the second table.
INTERSECT operator returns us only the matching or common rows between 2 result sets.
ANSWER
QUESTION 28
hirist QUESTION 29
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
30/103
For the hottest SQL jobs, please visit www.hirist.com
.com
What is Self Join and why is it required?
30
QUESTION
Self Join is the act of joining one table with itself. Self Join is often very useful to convert a hierarchical structure into
a flat structure
ANSWER
QUESTION 29
hirist QUESTION 30
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
31/103
For the hottest SQL jobs, please visit www.hirist.com
.com
How can we transpose a table using SQL (changing rows to column or vice-versa)?
31
QUESTION
The usual way to do it in SQL is to use CASE statement or DECODE statement.
ANSWER
QUESTION 30
hirist QUESTION 31
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
32/103
For the hottest SQL jobs, please visit www.hirist.com
.com
What are the differences among ROWNUM, RANK and DENSE_RANK?
32
QUESTION
ROW_NUMBER assigns contiguous, unique numbers from 1.. N to a result set.
RANK does not assign unique numbersnor does it assign contiguous numbers. If two records tie for second
place, no record will be assigned the 3rd rank as no one came in third, according to RANK.
DENSE_RANK, like RANK, does not assign unique numbers, but it does assign contiguous numbers. Even though
two records tied for second place, there is a third-place record.
ANSWER
Q 3
hirist QUESTION 32
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
33/103
For the hottest SQL jobs, please visit www.hirist.com
.com
What is a database transaction?
33
QUESTION
Database transaction take database from one consistent state to another. At the end of the transaction the system
must be in the prior state if transaction fails or the status of the system should reflect the successful completion if
the transaction goes through.
ANSWER
Q 3
hirist QUESTION 33
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
34/103
For the hottest SQL jobs, please visit www.hirist.com
.com
What are properties of a transaction?
34
QUESTION
Properties of the transaction can be summarized as ACID Properties.
1. Atomicity: A transaction consists of many steps. When all the steps in a transaction gets completed, it will get
reflected in DB or if any step fails, all the transactions are rolled back.
2. Consistency: The database will move from one consistent state to another, if the transaction succeeds and
remain in the original state, if the transaction fails.
3. Isolation: Every transaction should operate as if it is the only transaction in the system
4. Durability: Once a transaction has completed successfully, the updated rows/records must be available for all
other transactions on a permanent basis
ANSWER
Q 33
hiristcom
QUESTION 34
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
35/103
For the hottest SQL jobs, please visit www.hirist.com
.com
What is a Database Lock? What are the type of locks?
35
QUESTION
Database lock tell a transaction, if the data item in questions is currently being used by other transactions.
1. Shared Lock: When a shared lock is applied on data item, other transactions can only read the item, but can't
write into it.
2. Exclusive Lock: When a exclusive lock is applied on data item, other transactions can't read or write into the data
item.
ANSWER
hiristcom
QUESTION 35
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
36/103
For the hottest SQL jobs, please visit www.hirist.com
.com
What is a Composite Key?
36
QUESTION
A Composite primary key is a type of candidate key, which represents a set of columns whose values uniquely
identify every row in a table.
For example - if "Employee_ID" and "Employee Name" in a table is combined to uniquely identifies a row its called
a Composite Key.
ANSWER
hiristcom
QUESTION 36
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
37/103
For the hottest SQL jobs, please visit www.hirist.com
.com
What is a Composite Primary Key?
37
QUESTION
A Composite primary key is a set of columns whose values uniquely identify every row in a table. What it means is
that, table which contains composite primary key will be indexed based on columns specified in the primary key.
This key will be referred in Foreign Key tables.
For example - if combined effect of columns, "Employee_ID" and "Employee Name" in a table is required to uniquely
identifies a row, its called a Composite Primary Key. In this case, both the columns will be represented as primary
key.
ANSWER
hiristcom
QUESTION 37
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
38/103
For the hottest SQL jobs, please visit www.hirist.com
.com
Define SQL Insert Statement?
38
QUESTION
SQL INSERT statement is used to add rows to a table. For a full row insert, SQL Query should start withinsertinto
statementfollowed by table name and values command, followed by the values that need to be inserted into the
table. Insert can be used in several ways:
1. To insert a single complete row
2. To insert a single partial row
ANSWER
hiristcom
QUESTION 38
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
39/103
For the hottest SQL jobs, please visit www.hirist.com
.com
Define SQL Update Statement?
39
QUESTION
SQL Update is used to update data in a row or set of rows specified in the filter condition.
The basic format of an SQL UPDATE statement is ,Update command followed by table to be updated and SET
command followed by column names and their new values followed by filter condition that determines which rows
should be updated.
ANSWER
hirist.com
QUESTION 39
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
40/103
For the hottest SQL jobs, please visit www.hirist.com
.com
What are wild cards used in database for Pattern Matching?
40
QUESTION
SQL Like operator is user for pattern matching. SQL 'Like' command takes more time to process. So before using
like operator, consider suggestions given below on when and where to use wild card search.
1) Don't overuse wild cards. If another search operator will do, use it instead.
2) When you do use wild cards, try not to use them at the beginning of the search pattern, unless absolutely
necessary. Search patterns that begin with wild cards are the slowest to process.
3) Pay careful attention to the placement of the wild card symbols. If they are misplaced, you might not return the
data you intended
ANSWER
hirist.com
QUESTION 40
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
41/103
For the hottest SQL jobs, please visit www.hirist.com
.com
What is Cross Join?
41
QUESTION
Cross Join will return all records where each row from the first table is combined with each row from the second
table.
ANSWER
hirist.com
QUESTION 41
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
42/103
For the hottest SQL jobs, please visit www.hirist.com
What is a view?
42
QUESTION
Views are virtual tables. Unlike tables that contain data, views simply contain queries that dynamically retrieve data
when used.
ANSWER
hirist.com
QUESTION 42
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
43/103
For the hottest SQL jobs, please visit www.hirist.com
What is a materialized view?
43
QUESTION
Materialized views is also a view but are disk based. Materialized views get updated on specific duration, base upon
the interval specified in the query definition. We can index materialized view.
ANSWER
hirist.com
QUESTION 43
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
44/103
For the hottest SQL jobs, please visit www.hirist.com
What are the advantages and disadvantages of views in a database?
44
QUESTION
Advantages:
1. Views doesn't store data in a physical location.
2. View can be use to hide some of the columns from the table
3. Views can provide Access Restriction, since data insertion, update and deletion is not possible on the view.
Disadvantages:
1. When a table is dropped, associated view become irrelevant.
2. Since view are created when a query requesting data from view is triggered, its bit slow
3. When views are created for large tables, it occupy more memory.
ANSWER
hirist.com
QUESTION 44
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
45/103
For the hottest SQL jobs, please visit www.hirist.com
When do you use UPDATE_STATISTICS command?
45
QUESTION
This command is used when a large processing of data has occurred. If any large amount of deletions, any
modifications, or Bulk Copy into the tables has occurred, it has to update the indexes to take these changes into
account. UPDATE_STATISTICS updates the indexes on these tables accordingly.
ANSWER
hirist.com
QUESTION 45
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
46/103
For the hottest SQL jobs, please visit www.hirist.com
What is an IDENTITY column in insert statements?
46
QUESTION
IDENTITY column is used in table columns to make that column as Auto incremental number or a surrogate key.
ANSWER
hirist.com
QUESTION 46
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
47/103
For the hottest SQL jobs, please visit www.hirist.com
How will I retrieve all records of employment 1 those should not be present n
employment 2?
47
QUESTION
(Select * from employment 2)-(Select * from employment 1).
ANSWER
hirist.com
QUESTION 47
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
48/103
For the hottest SQL jobs, please visit www.hirist.com
Which TCP/IP port does SQL Server run on? How can it be changed?
48
QUESTION
SQL Server runs on port 1433. It can be changed from the Network Utility TCP/IP properties.
ANSWER
hirist.com
QUESTION 48
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
49/103
For the hottest SQL jobs, please visit www.hirist.com
What is SQL Server Agent?
49
QUESTION
SQL Server agent plays an important role in the day-to-day tasks of a database administrator (DBA). Its purpose is
to ease the implementation of tasks for the DBA, with its full- function scheduling engine, which allows you to
schedule your own jobs and scripts.
ANSWER
hirist.com
QUESTION 49
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
50/103
For the hottest SQL jobs, please visit www.hirist.com
Which command using Query Analyzer will give you the version of SQL server and
operating system?
50
QUESTION
SELECT SERVERPROPERTY ('productversion'), SERVERPROPERTY ('productlevel') and SERVERPROPERTY
('edition')
ANSWER
hirist.com
QUESTION 51
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
51/103
For the hottest SQL jobs, please visit www.hirist.com
How to create recursive query in SQL Server?
51
QUESTION
Recursive query can be create in SQL using stored procedure but you can also use CTE (Common table
expression). It might be also worth asking about performance as CTE is not always very fast.
ANSWER
hirist.com
QUESTION 51
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
52/103
For the hottest SQL jobs, please visit www.hirist.com
What is a constraint?
52
QUESTION
Constraint can be used to specify the limit on the data type of table. Constraint can be specified while creating or
altering the table statement. Sample of constraint are.
NOT NULL.
CHECK.
DEFAULT.
UNIQUE.
PRIMARY KEY.
FOREIGN KEY.
ANSWER
hirist.com
QUESTION 52
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
53/103
For the hottest SQL jobs, please visit www.hirist.com
What is Auto Increment?
53
QUESTION
Auto increment keyword allows the user to create a unique number to be generated when a new record is inserted
into the table. AUTO INCREMENT keyword can be used in Oracle and IDENTITY keyword can be used in SQL
SERVER.
Mostly this keyword can be used whenever PRIMARY KEY is used.
ANSWER
hirist.com
QUESTION 53
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
54/103
For the hottest SQL jobs, please visit www.hirist.com
What is Datawarehouse?
54
QUESTION
Datawarehouse is a central repository of data from multiple sources of information. Those data are consolidated,
transformed and made available for the mining and online processing. Warehouse data have a subset of data
called Data Marts.
ANSWER
hirist.com
QUESTION 54
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
55/103
For the hottest SQL jobs, please visit www.hirist.com
What is user defined functions?
55
QUESTION
User defined functions are the functions written to use that logic whenever required. It is not necessary to write the
same logic several times. Instead, function can be called or executed whenever needed.
ANSWER
hirist.com
QUESTION 55
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
56/103
For the hottest SQL jobs, please visit www.hirist.com
What are all types of user defined functions?
56
QUESTION
Three types of user defined functions are.
a.Scalar Functions.
b. Inline Table valued functions.
c. Multi statement valued functions.
ANSWER
hirist.com
QUESTION 56
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
57/103
For the hottest SQL jobs, please visit www.hirist.com
What are all different types of collation sensitivity?
57
QUESTION
Following are different types of collation sensitivity -.
Case SensitivityA and a and B and b.
Accent Sensitivity.
Kana SensitivityJapanese Kana characters.
Width SensitivitySingle byte character and double byte character.
ANSWER
hirist.com
QUESTION 57
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
58/103
For the hottest SQL jobs, please visit www.hirist.com
What is Online Transaction Processing (OLTP)?
58
QUESTION
Online Transaction Processing or OLTP manages transaction based applications which can be used for data entry
and easy retrieval processing of data. This processing makes like easier on simplicity and efficiency. It is faster,
more accurate results and expenses with respect to OTLP.
ExampleBank Transactions on a daily basis.
ANSWER
hirist.com
QUESTION 58
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
59/103
For the hottest SQL jobs, please visit www.hirist.com
What is an ALIAS command?
59
QUESTION
ALIAS name can be given to a table or column. This alias name can be referred in WHERE clause to identify the
table or column.
Example-.
Select st.StudentID, Ex.Result from student st, Exam as Ex where st.studentID = Ex. StudentID
Here, st refers to alias name for student table and Ex refers to alias name for exam table.
ANSWER
hirist.com
QUESTION 59
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
60/103
For the hottest SQL jobs, please visit www.hirist.com
What are aggregate and scalar functions?
60
QUESTION
Aggregate functions are used to evaluate mathematical calculation and return single values. This can be calculated
from the columns in a table. Scalar functions return a single value based on the input value.
Example -.
Aggregatemax(), countCalculated with respect to numeric.
ScalarUCASE(), NOW()Calculated with respect to strings.
ANSWER
hirist.com
QUESTION 60
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
61/103
For the hottest SQL jobs, please visit www.hirist.com
How can you create an empty table from an existing table?
61
QUESTION
Select * into studentcopy from student where 1=2
Here, we are copying student table to another table with the same structure with no rows copied.
ANSWER
hirist.com
QUESTION 61
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
62/103
For the hottest SQL jobs, please visit www.hirist.com
How to fetch common records from two tables?
62
QUESTION
Common records result set can be achieved by -.
Select studentID from student. INTERSECT Select StudentID from Exam
ANSWER
hirist.com
QUESTION 62
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
63/103
For the hottest SQL jobs, please visit www.hirist.com
How to select unique records from a table?
63
QUESTION
Select unique records from a table by using DISTINCT keyword.
Select DISTINCT StudentID, StudentName from Student.
ANSWER
hirist.com
QUESTION 63
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
64/103
For the hottest SQL jobs, please visit www.hirist.com
What are the different index configurations a table can have?
64
QUESTION
A table can have one of the following index configurations:
1.No indexes
2.A clustered index
3.A clustered index and many nonclustered indexes
4.A nonclustered index
5.Many nonclustered indexes
ANSWER
hirist.com
QUESTION 64
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
65/103
For the hottest SQL jobs, please visit www.hirist.com
What are the properties and different Types of Sub-Queries?
65
QUESTION
Properties of Sub-Query
a.A sub-query must be enclosed in the parenthesis.
b.A sub-query must be put in the right hand of the comparison operator, and
c. A sub-query cannot contain an ORDER-BY clause.
d.A query can contain more than one sub-query.
Types of Sub-Query
e. Single-row sub-query, where the sub-query returns only one row.
f. Multiple-row sub-query, where the sub-query returns multiple rows,. and
g.Multiple column sub-query, where the sub-query returns multiple columns
ANSWER
hirist.com
QUESTION 65
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
66/103
For the hottest SQL jobs, please visit www.hirist.com
What is SQL Profiler?
66
QUESTION
SQL Profiler is a graphical tool that allows system administrators to monitor events in an instance of Microsoft SQL
Server. You can capture and save data about each event to a file or SQL Server table to analyze later. For
example, you can monitor a production environment to see which stored procedures are hampering performancesby executing too slowly.
Use SQL Profiler to monitor only the events in which you are interested. If traces are becoming too large, you can
filter them based on the information you want, so that only a subset of the event data is collected. Monitoring too
many events adds overhead to the server and the monitoring process and can cause the trace file or trace table
to grow very large, especially when the monitoring process takes place over a long period of time.
ANSWER
hirist.com
QUESTION 66
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
67/103
For the hottest SQL jobs, please visit www.hirist.com
What are the authentication modes in SQL Server? How can it be changed?
67
QUESTION
Windows mode and Mixed Mode - SQL and Windows. To change authentication mode in SQL Server click Start,
Programs, Microsoft SQL Server and click SQL Enterprise Manager to run SQL Enterprise Manager from the
Microsoft SQL Server program group. Select the server then from the Tools menu select SQL ServerConfiguration Properties, and choose the Security page.
ANSWER
hirist.com
QUESTION 67
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
68/103
For the hottest SQL jobs, please visit www.hirist.com
Can a stored procedure call itself or recursive stored procedure? How much level
SP nesting is possible?
68
QUESTION
Yes. Because Transact-SQL supports recursion, you can write stored procedures that call themselves. Recursion
can be defined as a method of problem solving wherein the solution is arrived at by repetitively applying it to
subsets of the problem. A common application of recursive logic is to perform numeric computations that lendthemselves to repetitive evaluation by the same processing steps. Stored procedures are nested when one stored
procedure calls another or executes managed code by referencing a CLR routine, type, or aggregate. You can
nest stored procedures and managed code references up to 32 levels.
ANSWER
hirist.com
QUESTION 68
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
69/103
For the hottest SQL jobs, please visit www.hirist.com
What is Log Shipping?
69
QUESTION
Log shipping is the process of automating the backup of database and transaction log files on a production SQL
server, and then restoring them onto a standby server. Enterprise Editions only supports log shipping. In log
shipping the transactional log file from one server is automatically updated into the backup database on the other
server. If one server fails, the other server will have the same db and can be used this as the Disaster Recovery
plan. The key feature of log shipping is that it will automatically backup transaction logs throughout the day and
automatically restore them on the standby server at defined interval.
ANSWER
hirist.com
QUESTION
QUESTION 69
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
70/103
For the hottest SQL jobs, please visit www.hirist.com
Name 3 ways to get an accurate count of the number of records in a table?
70
QUESTION
SELECT * FROM table1
SELECT COUNT(*) FROM table1
SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1)AND indid < 2
ANSWER
hirist.com
QUESTION
QUESTION 70
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
71/103
For the hottest SQL jobs, please visit www.hirist.com
What does it mean to have QUOTED_IDENTIFIER ON? What are the implications of
having it OFF?
71
QUESTION
When SET QUOTED_IDENTIFIER is ON, identifiers can be delimited by double quotation marks, and literals must
be delimited by single quotation marks. When SET QUOTED_IDENTIFIER is OFF, identifiers cannot be quoted
and must follow all Transact-SQL rules for identifiers.
ANSWER
hirist.com
QUESTION
QUESTION 71
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
72/103
For the hottest SQL jobs, please visit www.hirist.com
What is the difference between a Local and a Global temporary table?
72
QUESTION
1. A local temporary table exists only for the duration of a connection or, if defined inside a compound statement, for
the duration of the compound statement.
2.A global temporary table remains in the database permanently, but the rows exist only within a given connection.When connection is closed, the data in the global temporary table disappears. However, the table definition
remains with the database for access when database is opened next time.
ANSWER
hirist.com
QUESTION
QUESTION 72
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
73/103
For the hottest SQL jobs, please visit www.hirist.com
How Global temporary tables are represented and its scope?
73
QUESTION
Global temporary tables are represented with ## before the table name. Scope will be the outside the session
whereas local temporary tables are inside the session. Session ID can be found using @@SPID.
ANSWER
hirist.com
QUESTION
QUESTION 73
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
74/103
For the hottest SQL jobs, please visit www.hirist.com
What is the STUFF function and how does it differ from the REPLACE function?
74
QUESTION
STUFF function is used to overwrite existing characters. Using this syntax, STUFF (string_expression, start, length,
replacement_characters), string_expression is the string that will have characters substituted, start is the starting
position, length is the number of characters in the string that are substituted, and replacement_characters are the
new characters interjected into the string. REPLACE function to replace existing characters of all occurrences.
Using the syntax REPLACE (string_expression, search_string, replacement_string), where every incidence of
search_string found in the string_expression will be replaced with replacement_string.
ANSWER
hirist.com
QUESTION
QUESTION 74
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
75/103
For the hottest SQL jobs, please visit www.hirist.com
What is CHECK Constraint?
75
QUESTION
A CHECK constraint is used to limit the values that can be placed in a column. The check constraints are used to
enforce domain integrity.
ANSWER
hirist.com
QUESTION
QUESTION 75
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
76/103
For the hottest SQL jobs, please visit www.hirist.com
What is the difference between UNION and UNION ALL?
76
QUESTION
UNION statement is mainly used to combine the tables including the duplicate rows and UNION ALL combine but
does not look for duplicate rows. With this, UNION ALL will be very faster than UNION statements.
ANSWER
hirist.com
QUESTION
QUESTION 76
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
77/103
For the hottest SQL jobs, please visit www.hirist.com
What is NOT NULL Constraint?
77
QUESTION
A NOT NULL constraint enforces that the column will not accept null values. The not null constraints are used to
enforce domain integrity, as the check constraints.
ANSWER
hirist.com
QUESTION
QUESTION 77
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
78/103
For the hottest SQL jobs, please visit www.hirist.com
How to get @@ERROR and @@ROWCOUNT at the same time?
78
QUESTION
If @@Rowcount is checked after Error checking statement then it will have 0 as the value of @@Recordcount as it
would have been reset. And if @@Recordcount is checked before the error-checking statement then @@Error
would get reset. To get @@error and @@rowcount at the same time do both in same statement and store them
in local variable.
SELECT @RC = @@ROWCOUNT, @ER = @@ERROR
ANSWER
hirist.com
QUESTION
QUESTION 78
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
79/103
For the hottest SQL jobs, please visit www.hirist.com
What is a Scheduled Jobs or What is a Scheduled Tasks?
79
QUESTION
Scheduled tasks let user automate processes that run on regular or predictable cycles. User can schedule
administrative tasks, such as cube processing, to run during times of slow business activity. User can also
determine the order in which tasks run by creating job steps within a SQL Server Agent job. E.g. back up
database, Update Stats of Tables. Job steps give user control over flow of execution. If one job fails, user can
configure SQL Server Agent to continue to run the remaining tasks or to stop execution.
ANSWER
hirist.com
QUESTION
QUESTION 79
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
80/103
For the hottest SQL jobs, please visit www.hirist.com
What is a table called, if it has neither Cluster nor Non-cluster Index? What is it
used for?
80
Q
Unindexed table or Heap. Microsoft Press Books and Book on Line (BOL) refers it as Heap. A heap is a table that
does not have a clustered index and, therefore, the pages are not linked by pointers. The IAM pages are the only
structures that link the pages in a table together. Unindexed tables are good for fast storing of data. Many times it
is better to drop all indexes from table and then do bulk of inserts and to restore those indexes after that.
ANSWER
hirist.com
QUESTION
QUESTION 80
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
81/103
For the hottest SQL jobs, please visit www.hirist.com
Can SQL Servers linked to other servers like Oracle?
81
SQL Server can be linked to any server provided it has OLE-DB provider from Microsoft to allow a link. E.g. Oracle
has an OLE-DB provider for oracle that Microsoft provides to add it as linked server to SQL Server group.
ANSWER
hirist.com
QUESTION
QUESTION 81
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
82/103
For the hottest SQL jobs, please visit www.hirist.com
What is BCP? When does it used?
82
BulkCopy is a tool used to copy huge amount of data from tables and views. BCP does not copy the structures
same as source to destination. BULK INSERT command helps to import a data file into a database table or view
in a user-specified format.
ANSWER
hirist.com
QUESTION
QUESTION 82
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
83/103
For the hottest SQL jobs, please visit www.hirist.com
How to implement one-to-one, one-to-many and many-to-many relationships while
designing tables?
83
One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key
relationships. One-to-Many relationships are implemented by splitting the data into two tables with primary key
and foreign key relationships. Many-to-Many relationships are implemented using a junction table with the keys
from both the tables forming the composite primary key of the junction table.
ANSWER
hirist.com
QUESTION
QUESTION 83
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
84/103
For the hottest SQL jobs, please visit www.hirist.com
What is an execution plan? When would you use it? How would you view the
execution plan?
84
An execution plan is basically a road map that graphically or textually shows the data retrieval methods chosen by
the SQL Server query optimizer for a stored procedure or ad- hoc query and is a very useful tool for a developer
to understand the performance characteristics of a query or stored procedure since the plan is the one that SQL
Server will place in its cache and use to execute the stored procedure or query. From within Query Analyzer is an
option called "Show Execution Plan" (located on the Query drop-down menu). If this option is turned on it will
display query execution plan in separate window when query is ran again.
ANSWER
hirist.com
QUESTION
QUESTION 84
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
85/103
For the hottest SQL jobs, please visit www.hirist.com
What are the two authentication modes in SQL Server?
85
There are two authentication modes
Windows Mode
Mixed Mode
Modes can be changed by selecting the tools menu of SQL Server configuration properties and choose security
page.
ANSWER
hirist.com
QUESTION
QUESTION 85
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
86/103
For the hottest SQL jobs, please visit www.hirist.com
What is COALESCE in SQL Server?
86
COALESCE is used to return first non-null expression within the arguments. This function is used to return a non-
null from more than one column in the arguments.
Example
Select COALESCE(empno, empname, salary) from employee;
ANSWER
hirist.com
QUESTION
QUESTION 86
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
87/103
For the hottest SQL jobs, please visit www.hirist.com
How exceptions can be handled in SQL Server Programming?
87
Exceptions are handled using TRY-CATCH constructs and it is handles by writing scripts inside the TRY block
and error handling in the CATCH block.
ANSWER
hirist.com
QUESTION
QUESTION 87
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
88/103
For the hottest SQL jobs, please visit www.hirist.com
What is the purpose of FLOOR function?
88
FLOOR function is used to round up a non-integer value to the previous least integer. Example is given FLOOR(6.7)
Returns 6.
ANSWER
hirist.com
QUESTION
QUESTION 88
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
89/103
For the hottest SQL jobs, please visit www.hirist.com
Can we check locks in database? If so, how can we do this lock check?
89
Yes, we can check locks in the database. It can be achieved by using in-built stored procedure called sp_lock.
ANSWER
hirist.com
QUESTION
QUESTION 89
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
90/103
For the hottest SQL jobs, please visit www.hirist.com
What is the use of SIGN function?
90
SIGN function is used to determine whether the number specified is Positive, Negative and Zero. This will return
+1,-1 or 0.
Example: SIGN(-35) returns -1
ANSWER
hirist.com
QUESTION
QUESTION 90
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
91/103
For the hottest SQL jobs, please visit www.hirist.com
How is the SUBSTR keyword used in SQL?
91
SUBSTR is used for string manipulation with column name, first position and string length used as arguments. E.g.
SUBSTR (NAME, 1 3) refers to the first three characters in the column NAME.
ANSWER
hirist.com
QUESTION
QUESTION 91
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
92/103
For the hottest SQL jobs, please visit www.hirist.com
What is a NULL value? What are the pros and cons of using NULLS?
92
A NULL value takes up one byte of storage and indicates that a value is not present as opposed to a space or zero
value. It's the DB2 equivalent of TBD on an organizational chart and often correctly portrays a business situation.
Unfortunately, it requires extra coding for an application program to handle this situation.
ANSWER
hirist.com
QUESTION
QUESTION 92
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
93/103
For the hottest SQL jobs, please visit www.hirist.com
What is a synonym? How is it used?
93
A synonym is used to reference a table or view by another name. The other name can then be written in the
application code pointing to test tables in the development stage and to production entities when the code is
migrated. The synonym is linked to the AUTHID that created it.
ANSWER
hirist.com
QUESTION
QUESTION 93
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
94/103
For the hottest SQL jobs, please visit www.hirist.com
What is a Cartesian product?
94
A Cartesian product results from a faulty query. It is a row in the results for every combination in the join tables.
ANSWER
hirist.com
QUESTION
QUESTION 94
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
95/103
For the hottest SQL jobs, please visit www.hirist.com
What is a tuple?
95
Static SQL is compiled and optimized prior to its execution; dynamic is compiled and optimized during execution.
ANSWER
hirist.com
Wh i f i l i i ?
QUESTION
QUESTION 95
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
96/103
For the hottest SQL jobs, please visit www.hirist.com
What is referential integrity?
96
Referential integrity refers to the consistency that must be maintained between primary and foreign keys, i.e. every
foreign key value must have a corresponding primary key value.
ANSWER
hirist.com
Wh t th i i f ?
QUESTION
QUESTION 96
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
97/103
For the hottest SQL jobs, please visit www.hirist.com
Whatsthe maximum size of a row?
97
8060 bytes.
ANSWER
hirist.com
H t h D t b i SQL ?
QUESTION
QUESTION 97
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
98/103
For the hottest SQL jobs, please visit www.hirist.com
How to change Database name in SQL server?
98
Use the following code:
Supported in SQL server 2000 and 2005
Exec sp_renamedbtest, test1Supported in SQL Server 2005 and later version
ALTER Databasetest1Modify Name =test
ANSWER
hirist.com
What is a Cursor?
QUESTION
QUESTION 98
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
99/103
For the hottest SQL jobs, please visit www.hirist.com
What is a Cursor?
99
A database Cursor is a control which enables traversal over the rows or records in the table. This can be viewed as
a pointer to one row in a set of rows. Cursor is very much useful for traversing such as retrieval, addition and
removal of database records.
ANSWER
hirist.com
What are Magic Tables in SQL Server?
QUESTION
QUESTION 99
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
100/103
For the hottest SQL jobs, please visit www.hirist.com
What are Magic Tables in SQL Server?
100
Insert and Delete tables are created when the trigger is fired for any DML command. Those tables are called Magic
Tables in SQL Server. These magic tables are used inside the triggers for data transaction.
ANSWER
hirist.com
What is ISNULL() operator?
QUESTION
QUESTION 100
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
101/103
For the hottest SQL jobs, please visit www.hirist.com
What is ISNULL() operator?
101
ISNULL function is used to check whether value given is NULL or not NULL in sql server. This function also provides
to replace a value with the NULL.
ANSWER
hirist.com Resources
http://www.itechaleart.com/2013/05/top-50-sql-question-answers_11.html
https://www katieandemil com/sql interview questions and
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
102/103
For the hottest SQL jobs, please visit www.hirist.com 102
https://www.katieandemil.com/sql-interview-questions-and-
answers?tab=article#Question 4
http://www.dwbiconcepts.com/tutorial/24-interview-questions/190-top-20-sql-
interview-questions-with-answers.html
http://a4academics.com/interview-questions/53-database-and-sql/411-sql-
interview-questions-and-answers-database
http://narendra86.blogspot.com/2013/10/top-80-sql-query-interview-
questions.html
http://crackaninterview.com/sql-queries-interview-questions-answers/http://career.guru99.com/top-50-sql-question-answers/
http://www.indiabix.com/technical/sql-server-common-questions/
http://career.guru99.com/top-50-sql-server-questions-answers/
http://www.ittestpapers.com/sql-interview-questions(25-50).html
http://www.dotnetfunda.com/interviews/cat/8/sql-server
http://www.careerride.com/SQLServer-Interview-Questions.aspx
www.hirist.com
http://www.hirist.com/k/sql-jobs-465.html?ref=sldhttp://www.hirist.com/k/sql-jobs-465.html?ref=sld7/25/2019 100 sql interview questions and answers
103/103
SQL
TOP 100INTERVIEW QUESTIONS & ANSWERS