February 16, 2019

Srikaanth

ServiceNow Frequently Asked SQL Server Interview Questions Answers

What are the advantages of the Mirroring?

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.

What is a Log Shipping?

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.

What are the advantages of Log shipping?

Advantages of Log shipping:

Easy to set up.
Secondary database can be used as a read-only purpose.
Multiple secondary standby servers are possible
Low maintenance.
ServiceNow Frequently Asked SQL Server Interview Questions Answers
ServiceNow Frequently Asked SQL Server Interview Questions Answers

Can we take the full database backup in Log shipping?

Yes, we can take the full database backup. It won’t affect the log shipping.

What is an execution plan?

An execution plan is a graphical or textual way of showing how SQL server breaks down a query to get the required result. It helps a user to determine why queries are taking more time to execute and based on the investigation user can update their queries for the maximum result.

In 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 a query execution plan in a separate window when a query is run again.

What is a performance monitor?

Windows performance monitor is a tool to capture metrics for the entire server. We can use this tool for capturing events of SQL server also.
Some useful counters are – Disks, Memory, Processors, Network etc.

What are 3 ways to get a count of the number of records in a table?

SELECT * FROM table_Name
SELECT COUNT(*) FROM table_Name
SELECT rows FROM indexes WHERE id = OBJECT_ID(tableName) AND indid< 2

Can we rename a column in the output of SQL query?

Yes by using the following syntax we can do this.

SELECT column_name AS new_name FROM table_name;

What is the difference between a Local and a Global temporary table?

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.

Why are Views required in the SQL Server or in any other database?

  Views are very beneficial because of the following reasons:

Views are required to hide the complexity that is involved in the database schema and also to customize the data for a particular set of users.
Views provide a mechanism to control the access to particular rows and columns.
These help in aggregating the data to improve the performance of the database.

What command is used to delete a table from the database in the SQL Server and how?

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.

Why is replication required on the SQL Server?

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.

What command is used to create a database in the SQL Server and how?

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.

What function does a database engine serve in the SQL Server?

Database Engine is a type of a 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.

What are the advantages of having an index on the SQL Server?

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.

What is the SQL Profiler?

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.

What do you mean by authentication modes in SQL Server?

There are two authentication modes in SQL Server.

Windows mode
Mixed Mode – SQL and Windows.

How can we check the SQL Server version?

By running the following command:

SELECT @@Version

Is it possible to call a stored procedure within a stored procedure?

Yes, we call a stored procedure within a stored procedure It is called recursion property of SQL server and these type of stored procedures are called nested stored procedures.

What are the common performance issues in SQL Server?

Following are the common performance issues:

Deadlocks
Blocking
Missing and unused indexes.
I/O bottlenecks
Poor Query plans
Fragmentation

List the various tools available for performance tuning?

There are various tools available for performance tuning:

Dynamic Management Views
SQL Server Profiler
Server Side Traces
Windows Performance monitor.
Query Plans
Tuning advisor

What is FOREIGN KEY

When a one table’s primary key field is added to related tables in order to create the common field which relates the two tables, it called a foreign key in other tables.

Foreign Key constraints enforce referential integrity.

What is a CHECK Constraint?

A CHECK constraint is used to limit the values or type of data that can be stored in a column. They are used to enforce domain integrity.

What are a Scheduled Jobs?

Scheduled job allows a user to run the scripts or SQL commands automatically on the scheduled basis. User can determine the order in which commands need to execute and the best time to run the job to avoid the load on the system.

What is a heap?

A heap is a table that does not contain any clustered index or non-clustered index.

What is BCP?

BCP or Bulk Copy is a tool by which we can copy a large amount of data to 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.

What is a Linked Server?

Linked Servers is a concept by which we can connect another SQL server to a Group and query both the SQL Servers database using T-SQL Statements

sp_addlinkedsrvloginisssed to add link server.

What is Collation?

Collation refers to a set of rules that determine how data is sorted and compared. Character data is sorted using rules that define the correct character sequence, with options for specifying case sensitivity, accent marks, kana character types and character width.

What is a View?

A view is a virtual table which contains data from one or more tables. Views restrict data access of table by selecting only required values and make complex queries easy.

Rows updated or deleted in the view are updated or deleted in the table the view was created with. It should also be noted that as data in the original table changes, so does data in the view, as views are the way to look at part of the original table. The results of using a view are not permanently stored in the database

Subscribe to get more Posts :

2 comments

Write comments