For BE/B.Tech/BCA/MCA/ME/M.Tech Major/Minor Project for CS/IT branch at minimum price Text Message @ 9424820157

SQL Server Interview Questions

                    SQL Server Interview Questions



1. Which TCP/IP port does SQL Server run on?

By default SQL Server runs on port 1433.


2. What is the difference between clustered and non-clustered index?

A clustered index is an index that rearranges the table in the order of the index itself. Its leaf nodes contain data pages. A table can have only one clustered index.

A non-clustered index is an index that does not re-arrange the table in the order of the index itself. Its leaf nodes contain index rows instead of data pages. A table can have many non-clustered indexes.


3. List the different index configurations possible for a table?

A table can have one of the following index configurations:

No indexes

A clustered index

A clustered index and many non-clustered indexes

A non-clustered index

Many non-clustered indexes


4. What is the recovery model? List the types of recovery models available in SQL Server?

The recovery model tells SQL Server what data should be kept in the transaction log file and for how long. A database can have only one recovery model. It also tells SQL server which backup is possible in a particular selected recovery model.

There are three types of recovery models:

Full

Simple

Bulk-Logged


5. What are the different backups available in SQL Server?

Different possible backups are:

Full backup

Differential Backup

Transactional Log Backup

Copy Only Backup

File and Filegroup backup


6. What is a Full Backup?

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 the transaction log so that it can be recovered.


7. What is OLTP?

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.


8. What is RDBMS?

RDBMS or Relational Database Management Systems are database management systems that maintain data in the form of tables. We can create relationships between the tables. An RDBMS can recombine the data items from different files, providing powerful tools for data usage.


9. What are the properties of the Relational tables?

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.


10. What’s the difference between a primary key and a unique key?

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.


11. When is the UPDATE_STATISTICS command used?

As the name implies UPDATE_STATISTICS command updates the statistics used by the index to make the search easier.


12. What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?

The differences between HAVING CLAUSE and WHERE CLAUSE is:

Both specify a search condition but the HAVING clause is used only with the SELECT statement and typically used with GROUP BY clause.

If the GROUP BY clause is not used, then the HAVING clause behaves like a WHERE clause only.


13. What is Mirroring?

Mirroring is a high-availability solution. It is designed to maintain a hot standby server that is consistent with the primary server in terms of a transaction. Transaction Log records are sent directly from the principal server to a secondary server which keeps a secondary server up to date with the principal server.


14. What are the advantages of Mirroring?

Advantages of Mirroring are:

It is more robust and efficient than Log shipping.

It has an automatic failover mechanism.

The secondary server is synced with the primary in near real-time.


15. What is Log Shipping?

Log shipping is nothing but the automation of backup and restores the 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.


16. What are the advantages of Log shipping?

Advantages of Log Shipping includes:

Easy to set up.

The secondary database can be used as a read-only purpose.

Multiple secondary standby servers are possible

Low maintenance.


17. 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.


18. What is an execution plan?

An execution plan is a graphical or textual way of showing how the 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.

Query Analyzer has 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 the query is run again.


19. What is the Stored Procedure?

A stored procedure is a set of SQL queries that can take input and send back output. And when the procedure is modified, all clients automatically get the new version. Stored procedures reduce network traffic and improve performance. Stored procedures can be used to help ensure the integrity of the database.


20. List the advantages of using Stored Procedures?

Advantages of using Stored procedures are:


Stored procedure boosts application performance.

Stored procedure execution plans can be reused as they are cached in SQL Server’s memory which reduces server overhead.

They can be reused.

It can encapsulate logic. You can change the stored procedure code without affecting clients.

They provide better security for your data.


21. What is identity in SQL?

An identity column in the SQL automatically generates numeric values. We can be defined as a start and increment value of the identity column. Identity columns do not need to be indexed.


22. 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


23. List the various tools available for performance tuning?

Various tools available for performance tuning are:

Dynamic Management Views

SQL Server Profiler

Server Side Traces

Windows Performance monitor.

Query Plans

Tuning advisor


24. 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 the SQL server also.

Some useful counters are – Disks, Memory, Processors, Network, etc.


25. 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;


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

Yes, by using the following syntax we can do this.

SELECT column_name AS new_name FROM table_name;


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

If defined 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.


28. What is the SQL Profiler?

SQL Profiler provides a graphical representation of events in an instance of SQL Server for 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.


29. 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.


30. How can we check the SQL Server version?

By running the following command:

SELECT @@Version


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

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


32. What is the SQL Server Agent?

SQL Server agent allows us to schedule the jobs and scripts. It helps in implementing the day-to-day DBA tasks by automatically executing them on a scheduled basis.


33. What is the PRIMARY KEY?

The primary key is a column whose values uniquely identify every row in a table. Primary key values can never be reused.


34. What is a UNIQUE KEY constraint?

A UNIQUE constraint enforces the uniqueness of the values in a set of columns, so no duplicate values are entered. The unique key constraints are used to enforce entity integrity as the primary key constraints.


35. What is FOREIGN KEY?

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

Foreign Key constraints enforce referential integrity.


36. 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.


37. What are Scheduled Jobs?

The scheduled job allows a user to run the scripts or SQL commands automatically on a scheduled basis. The user can determine the order in which command executes and the best time to run the job to avoid the load on the system.


38. What is a heap?

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


39. 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 the 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.


40. What is Normalization?

The process of table design to minimize the data redundancy is called normalization. We need to divide a database into two or more tables and define relationships between them. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables.


41. List the different normalization forms?

Different normalization forms are:


1NF (Eliminate Repeating Groups): Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.

2NF (Eliminate Redundant Data): If an attribute depends on only part of a multi-valued key, remove it to a separate table.

3NF (Eliminate Columns Not Dependent On Key): If attributes do not contribute to the description of the key, remove them to a separate table. All attributes must be directly dependent on the primary key.

BCNF (Boyce-Codd Normal Form): If there are non-trivial dependencies between candidate key attributes, separate them into distinct tables.

4NF (Isolate Independent Multiple Relationships): No table may contain two or more 1:n or n:m relationships that are not directly related.

5NF (Isolate Semantically Related Multiple Relationships): There may be practical constraints on information that justifies separating logically related many-to-many relationships.

ONF (Optimal Normal Form): A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.

DKNF (Domain-Key Normal Form): A model free from all modification is said to be in DKNF.


42. What is De-normalization?

De-normalization is the process of adding redundant data to a database to enhance the performance of it. It is a technique to move from higher to lower normal forms of database modeling to speed up database access.


43. What is a Trigger and types of a trigger?

The trigger allows us to execute a batch of SQL code when table event occurs (INSERT, UPDATE or DELETE command executed against a specific table). Triggers are stored in and managed by DBMS. It can also execute a stored procedure.

3 types of triggers that are available in the SQL Server are as follows:

DML Triggers: DML or Data Manipulation Language triggers are invoked whenever any of the DML commands like INSERT, DELETE or UPDATE happens on the table or the view.

DDL Triggers: DDL or Data Definition Language triggers are invoked whenever any changes occur in the definition of any of the database objects instead of actual data. These are very helpful to control the production and development of database environments.

Logon Triggers: These are very special triggers that fire in case of the logon event of the SQL Server. This is fired before the setup of a user session in the SQL Server.


44. What is the Subquery?

A Subquery is a subset of SELECT statements, whose return values are used in filtering conditions of the main query. It can occur in a SELECT clause, FROM clause and WHERE clause. It nested inside a SELECT, INSERT, UPDATE, or DELETE statement or inside another subquery.

Types of Sub-query:

Single-row sub-query: The subquery returns only one row

Multiple-row sub-query: The subquery returns multiple rows

Multiple column sub-query: The subquery returns multiple columns


45. What is a Linked Server?

Linked Server 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.


46. 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.


47. What is View?

A view is a virtual table that contains data from one or more tables. Views restrict data access of the 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


48. Where SQL server usernames and passwords are stored in a SQL server?

They get stored in System Catalog Views sys.server_principals and sys.sql_logins.


49. What are the properties of a transaction?

Generally, these properties are referred to as ACID properties.

They are:

Atomicity

Consistency

Isolation

Durability


50. Define UNION, UNION ALL, MINUS, INTERSECT?

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.


51. What is SQL Server used for?

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.


52. Which language is supported by SQL Server?

SQL Server is based upon the implementation of the SQL also known as Structured Query Language to work with the data inside the database.


53. Which is the latest version of SQL Server and when it is released?

SQL Server 2019 is the latest version of SQL Server that is available in the market and Microsoft launched this on November 4th, 2019 with the support of the Linux O/S.


54. What are the various editions of SQL Server 2019 that are available in the market?

SQL Server 2019 is available in 5 editions. These are as follows:

Enterprise: This delivers comprehensive high-end datacenter capabilities with blazing-fast performance, unlimited virtualization, and end-to-end business intelligence for mission-critical workloads and end-user access to data insights.

Standard: This delivers basic data management and business intelligence database for departments and small organizations to run their applications and supports common development tools for on-premises and cloud-enabling effective database management.

Web: This edition is a low total-cost-of-ownership option for Web hosters and Web VAPs to provide scalability, affordability, and manageability capabilities for small to large-scale Web properties.

Express: Express edition is the entry-level, free database and is ideal for learning and building desktop and small server data-driven applications.

Developer: This edition lets developers build any kind of application on top of SQL Server. It includes all the functionality of Enterprise edition, but is licensed for use as a development and test system, not as a production server.


55. What are functions in the SQL Server?

Functions are the sequence of the statements which accept inputs, process the inputs to perform some specific task and then provide the outputs. Functions should have some meaningful name but these should not start with a special character such as %,#,@, etc.

No comments:

Post a Comment



Please go through below tutorials:


Mule 4 Tutorials

DEPLOY TO CLOUDHUB C4E CLIENT ID ENFORCEMENT CUSTOM POLICY RABBIT MQ INTEGRATION
XML TO JSON WEBSERVICE CONSUMER VM CONNECTOR VALIDATION UNTIL SUCCESSFUL
SUB FLOW SET & REMOVE VARIABLE TRANSACTION ID SCATTER GATHER ROUND ROBIN
CONSUME REST WEBSERVICE CRUD OPERATIONS PARSE TEMPLATE OBJECT TO JSON LOAD STATIC RESOURCE
JSON TO XML INVOKE IDEMPOTENT FILTER FOR EACH FLAT TO JSON
FIXWIDTH TO JSON FIRST SUCCESSFUL FILE OPERATIONS EXECUTE ERROR HANDLING
EMAIL FUNCTIONALITY DYNAMIC EVALUATE CUSTOM BUSINESS EVENT CSV TO JSON COPYBOOK TO JSON
CHOICE ASYNC

Widely used Connectors in Mule 3

CMIS JETTY VM CONNECTOR SALESFORCE POP3
JMS TCP/IP WEBSERVICE CONSUMER QUARTZ MONGO DB
FILE CONNECTOR DATABASE CONNECTOR


Widely used Scopes in Mule 3

SUB FLOW REQUEST REPLY PROCESSOR CHAIN FOR EACH CACHE
ASYNC TCP/IP COMPOSITE SOURCE POLL UNTIL SUCCESSFUL
TRANSACTIONAL FLOW

Widely used Components in Mule 3

EXPRESSION CXF SCRIPT RUBY PYTHON
JAVASCRIPT JAVA INVOKE CUSTOM BUSINESS EVENT GROOVY
ECHO LOGGER


Widely used Transformers in Mule 3

MONGO DB XSLT TRANSFORMER REFERENCE SCRIPT RUBY
PYTHON MESSAGE PROPERTIES JAVA TRANSFORMER GZIP COMPRESS/UNCOMPRESS GROOVY
EXPRESSION DOM TO XML STRING VALIDATION COMBINE COLLECTIONS BYTE ARRAY TO STRING
ATTACHMENT TRANSFORMER FILE TO STRING XML TO DOM APPEND STRING JAVASCRIPT
JSON TO JAVA COPYBOOK TO JSON MAP TO JSON JSON TO XML FLATFILE TO JSON
FIXWIDTH TO JSON CSV TO JSON


Widely used Filters in Mule 3

WILDCARD SCHEMA VALIDATION REGEX PAYLOAD OR
NOT MESSAGE PROPERTY MESSAGE IDEMPOTENT FILTER REFERNCE
EXPRESSION EXCEPTION CUSTOM AND


Exception Strategy in Mule 3

REFERENCE EXCEPTION STRATEGY CUSTOM EXCEPTION STRATEGY CHOICE EXCEPTION STRATEGY CATCH EXCEPTION STRATEGY GLOBAL EXCEPTION STRATEGY


Flow Control in Mule 3

CHOICE COLLECTION AGGREGATOR COLLECTION SPLITTER CUSTOM AGGREGATOR FIRST SUCCESSFUL
MESSAGE CHUNK AGGREGATOR MESSAGE CHUNK SPLITTER RESEQUENCER ROUND ROBIN SOAP ROUTER