Sqlserver Interview Question
Sqlserver Interview Question
Let's start.
Full
Simple
Bulk-Logged
Q#5. What are different backups available in SQL Server?
Ans. Different possible backups are:
Full backup
Differential Backup
Transactional Log Backup
Copy Only Backup
File and Filegroup backup
Q#6. What is a FULL Backup?
Ans. A full backup is the most common type of backup in SQL Server. This is the complete
backup of the database. It also contains part of transaction log so it can be recovered.
Q#7. What is OLTP?
Ans. OLTP means Online transaction processing which follows rules of data normalization
to ensure data integrity. Using these rules complex information is broken down into a most
simple structure.
Q#8. What is RDBMS?
Ans. RDBMS or Relational Data Base Management Systems are database management
systems that maintain data in the form of tables. We can create relationships between the
tables. An RDBMS has the capability to recombine the data items from different files,
providing powerful tools for data usage.
Q#9. What are the properties of the Relational tables?
Ans. Relational tables have six properties:
Values are atomic.
Column values are of the same kind.
Each row is unique.
The sequence of columns is insignificant.
The sequence of rows is insignificant.
Each column must have a unique name.
Q#10. What's the difference between a primary key and a unique key?
Ans. The differences between the primary key and a unique key are:
The primary key is a column whose values uniquely identify every row in a table.
Primary key values can never be reused. They create a clustered index on the
column and cannot be null.
A Unique key is a column whose values also uniquely identify every row in a table
but they create a non-clustered index by default and it allows one NULL only.
Q#11. When is UPDATE_STATISTICS command used?
Ans. As the name implies UPDATE_STATISTICS command updated the statistics used by
the index to make the search easier.
Q#12. What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
Ans. The differences between HAVING CLAUSE and WHERE CLAUSE are:
Both specify a search condition but Having clause is used only with the SELECT
statement and typically used with GROUP BY clause.
If GROUP BY clause is not used then Having behaved like WHERE clause only.
Q#13. What is Mirroring?
Ans. Mirroring is a high availability solution. It is designed to maintain a hot standby server
which is consistent with the primary server in terms of a transaction. Transaction Log
records are sent directly from principal server to a secondary server which keeps a
secondary server up to date with the principal server.
Q#14. What are the advantages of the Mirroring?
Ans. Advantages of Mirroring are:
It is more robust and efficient that Log shipping.
It has an automatic failover mechanism.
The secondary server is synced with the primary in near real time.
Q#15. What is Log Shipping?
Ans. Log shipping is nothing but the automation of backup and restores of a database from
one server to another standalone standby server. This is one of the disaster recovery
solutions. If one server fails for some reason we will have the same data available on the
standby server.
Q#27. What is the difference between a Local and a Global temporary table?
Ans. If defined in inside a compound statement a local temporary table exists only for the
duration of that statement but a global temporary table exists permanently in the database
but its rows disappear when the connection is closed.
Q#28. What is the SQL Profiler?
Ans. SQL Profiler provides a graphical representation of events in an instance of SQL
Server for the monitoring and investment purpose. We can capture and save the data for
further analysis. We can put filters as well to captures the specific data we want.
Q#29. What do you mean by authentication modes in SQL Server?
Ans. There are two authentication modes in SQL Server.
Windows mode
Mixed Mode – SQL and Windows.
Q#30. How can we check the SQL Server version?
Ans. By running the following command:
SELECT @@Version
Q#48. Where SQL server usernames and passwords are stored in a SQL server?
Ans. They get stored in System Catalog Views sys.server_principals and sys.sql_logins.
Q#49. What are the properties of a transaction?
Ans. Generally, these properties are referred to as ACID properties. They are:
Atomicity
Consistency
Isolation
Durability
Q#50. Define UNION, UNION ALL, MINUS, INTERSECT?
Ans. UNION – returns all distinct rows selected by either query.
UNION ALL – returns all rows selected by either query, including all duplicates.
MINUS – returns all distinct rows selected by the first query but not by the second.
INTERSECT – returns all distinct rows selected by both queries.
Q#51. What is SQL Server used for?
Ans. SQL Server is one of the very popular Relational Database Management Systems.
This is a product from Microsoft to store and manage the information in the database.
Q#52. Which language is supported by SQL Server?
Ans. SQL Server is based upon the implementation of the SQL also known as Structured
Query Language to work with the data inside the database.
Q#53. Which is the latest version of SQL Server and when it is released?
Ans. SQL Server 2017 is the latest version of SQL Server that is available in the market
and Microsoft launched this on 2 October 2017 with the support of the Linux O/S.
Q#54. What are the various editions of SQL Server 2017 that are available in the
market?
Ans. SQL Server 2017 is available in 4 editions. These are as follows:
Enterprise: This supports in leading the high performance for the Tier 1 database
along with the capability of supporting business intelligence and workloads of
advanced analytics.
Standard: This supports mid-tier applications to achieve fast performance. This can
be easily upgraded to an enterprise edition also without having any changes in the
coding part.
Express: This is available for free and supports the building
of web and mobile applications up to 10 GB in the size.
Developer: This supports building, testing and demonstrating applications in a non-
production.
Q#55. What are functions in the SQL Server?
Ans. Functions are the sequence of the statements which accepts inputs, process the
inputs to perform some specific task and then provides the outputs. Functions should have
some meaningful name but these should not start with a special character such as %,#,@,
etc.
Q#56. What is a User-Defined function in the SQL Server and what is its advantage?
Ans. User-Defined Function is a function which can be written as per the needs of the user
by implementing your own logic. The biggest advantage of this function is that the user is
not limited to pre-defined functions and can simplify the complex code of pre-defined
function by writing a simple code as per the needs.
This returns Scalar value or a table.
Q#57. Explain the creation and execution of a user-defined function in the SQL
Server?
Ans. A User-Defined function can be created in the following way:
Q#64. What are the different types of Columns Types Constraints in the SQL Server?
Ans. SQL Server provides 6 types of Constraints. These are as follows:
Not Null Constraint: This puts a constraint that the value of a column cannot be
null.
Default Constraint: This constraint provides some default value that can be
inserted in the column if no value is specified for that column.
Check Constraint
Unique Constraint
Primary Key Constraint
Foreign Key Constraint
Q#64. What command is used to delete a table from the database in the SQL Server
and how?
Ans. Delete Command is used to delete any table from the database in the SQL Server.
Following is the way to use this command:
Delete Name of the table
Ex: If the name of a table is “employee” then delete command to delete this table can be
written as Delete employee.
Q#65. Why is replication required on the SQL Server?
Ans. Replication is the mechanism which is used to synchronize the data among the
multiple servers with the help of a replica set.
This is mainly used to increase the capacity of the reading and to provide an option to its
users to select among various different servers to perform the read/write operations.
Q#66. What command is used to create a database in the SQL Server and how?
Ans. CREATEDATABASE Command is used to create any database in the SQL Server.
Following is the way to use this command:
CREATEDATABASE Name of the Database
Ex: If the name of a database is “employee” then create command to create this database
can be written as CREATEDATABASE employee.
Q#67. What function does a database engine serve in the SQL Server?
Ans. Database Engine is a type of service in the SQL Server which starts as soon as the
Operating System starts. This may run by default depending upon the settings in the O/S.
Q#68. What are the advantages of having an index on the SQL Server?
Ans. The index has the following advantages:
Index supports the mechanism of having faster data retrieval from the database.
This forms a data structure in a way which helps in minimizing the data
comparisons.
This improves the performance of the retrieval of the data from the database.