Skip to main content

SQL Server DBA interview questions.By Niraj Kumar


What are the steps to take to improve performance of a poor performing query?
  • Maximum use of indexes, stored procures should be done.
  • Avoid excessive use of complicated joins and cursors.
  • Avoid using conditional operators using columns of different tables.
  • Make use of computed columns and rewriting the query.
  •  
What is a deadlock and what is a live lock? How will you go about resolving deadlocks?A deadlock occurs when two or more processes waits for a resource that is acquired by or is under the control of another process. A live lock is similar to a deadlock except the process states keeps changing. The result of such state is that none of the process will be complete.Deadlock detection finds and resolves deadlocks. A WFG strategy is followed. WFG is wait for graph. In WFG, processes are represented by nodes while dependencies are represented by edges. Thus, if process A is waiting for a resource held by process B, there is an edge in the WFG from the node for process A to the node for process B. a cycle is this graph is a deadlock. WFG constantly checks for cycles or when a process is blocked and adds a new edge to the WFG.   When a cycle is found, a victim is selected and aborted.
What is blocking and how would you troubleshoot it?
:-Blocking occurs when two or more rows are locked by one SQL connection and a second connection to the SQL server requires a conflicting on lock on those rows. This results in the second connection to wait until the first lock is released.Troubleshooting blocking:
  • SQL scripts can be written that constantly monitor the state of locking and blocking on SQL Server
  • The common blocking scenarios must be identified and resolved.
  • The scripts output must be checked constantly,
  • The SQL profilers data must be examined regularly to detect blocking.
  •  
Explain the different types of BACKUPs available in SQL Server.
  • Complete database backup: This type of backup will backup all the information in the database. Used most commonly for disaster recovery and takes the longest time to backup.
Differential databse backup: The database is divided into partitions that have been modified since last complete backup. Most suitable for large databases. The most recent differential backup contains the changes from previous backups.Transaction log backups: Backups only the changes logged in the transaction log. The transaction log has all changes logged about a database. Once the changes are accommodated on the database, the log is truncated or backed up.File/File Group backups: used to recover individual files or file groups. Each filegroup can be individually backed up. This helps in recovery only the required file or filegroup for disaster recovery.
What is database isolation in SQL Server?Isolation in database defines how and when changes made by one transaction can be visible to other transactions. Different isolation levels are:
  • Serializable
  • Repeatable read
  • Read committed
  • Read uncommitted

What is a Schema in SQL Server 2005? Explain how to create a new Schema in a Database?  A schema is used to create database objects. It can be created using CREATE SCHEMA statement. The objects created can be moved between schemas. Multiple database users can share a single default schema.CREATE SCHEMA sample; Table creation Create table sample.sampleinfo{id int primary key,         
name varchar(20)}

Explain how to create a Scrollable Cursor with the SCROLL Option.
Using the SCROLL keyword while declaring a cursor allows fetching of rows in any sequence
Example:
DECLARE employee_curs SCROLL CURSOR FOR SELECT * FROM employee;
The active set of the cursor is stored can be accessed in any order without the need of opening and closing the cursor. The Scroll cursors can be set for select and function cursors but not insert or update statements.

Explain how to create a Dynamic Cursor with the DYNAMIC Option.
When a cursor is declared as DYNAMIC, the cursor reflects all changes made to the base tables as the cursor is scrolled around.
Declare cursor_name cursor
[ STATIC | KEYSET | DYNAMIC | FAST_FORWARD ]
FOR select_statement
The dynamic option does not support ABSOLUTE FETCH.

What are database files and filegroups?

Database files are used for mapping the database over some operating system files. Data and log information are separate. SQL server database has three types of database files:

Primary: starting point of a database. It also points to other files in database. Extension: .mdf
Secondary: All data files except primary data file is a part of secondary files. Extension: .ndf
Log files: All log information used to recover database. Extension: .ldf


Describe in brief Databases and SQL Server Databases Architecture.

SQL Server consists of a set of various components which fulfill data storage and data analysis needs for enterprise applications. Database architecture: All the data is stored in databases which is organized into logical components visible to the end users. It’s only the administrator who needs to actually deal with the physical storage aspect of the databases, whereas users only deal with database tables.

Every SQL Server instance has primarily 4 system database i.e. master, model, tempdb and msdb. All other databases are user created databases as per their needs and requirements.

A single SQL Server instance is capable of handling thousands of users working on multiple databases.

Comments

Popular posts from this blog

For Assignment Solution Contact Omegaitsolution.com https://www.omegaitsolution.com 9899682018 DEC 2018 NMIMS Solved Assignments,

For Assignment Solution Contact Omegaitsolution.com https://www.omegaitsolution.com 9899682018 1. The manager of a company was analysing the trend of the products of its company (Commodity Y) getting replaced by another substitute product available in the market which gives the same level of satisfaction to the consumers. Calculate the rate of Marginal Rate of Substitution and analyse the result. Combination Units of Commodity Y Units of Commodity X Total Utility a 40 10 U b 25 14 U c 17 19 U d 10 27 U e 7 38 U 2. Neha has just completed her MBA and joined a startup company. The company was planning to launch a new product in the market so the management wanted to understand the different factors that can impact the demand and supply of their products in the market. Help Neha to prepare a report on the factors impacting d

For Assignment Solution Contact Niraj kumar Call and whatsapp (9899682018) Mail:-Nirajkumar294@gmail.com

GET SOLVED ASSIGNMENTS AT NOMINAL COST For Assignment Solution Contact Niraj kumar Call and whatsapp (9899682018) Mail:-Nirajkumar294@gmail.com INTERNAL ASSIGNMENT APPLICABLE FOR JUNE 2019 EXAMINATION SEMESTER 2 ASSIGNMENTS Marketing Management 1. Assume you plan to purchase a new car for personal use. This will be the first car that you will be purchasing. Discuss various steps of consumer buying process that will be involved in purchasing a car.  2. M/s Furnideas wishes to sell furniture in the Indian Market. The company is known for their innovative ideas in furniture. The company has a global presence in selling furniture. The company sells to High, Middle and Lower Income group in different countries based on the segmentation. Furnideas appoints you as a consultant to guide them on types of segmentation that they should use for their furniture. 3. M/s Furnideas (as given in question 2) wants to promote its brand and products to create awareness and increase the sale of i

Networking interview questions .

What is LAN? LAN is a computer network that spans a relatively small area. Most LANs are confined to a single building or group of buildings. However, one LAN can be connected to other LANs over any distance via telephone lines and radio waves. A system of LANs connected in this way is called a wide-area network (WAN). Most LANs connect workstations and personal computers. Each node (individual computer) in a LAN has its own CPU with which it executes programs, but it also is able to access data and devices anywhere on the LAN. This means that many users can share expensive devices, such as laser printers, as well as data. Users can also use the LAN to communicate with each other, by sending e-mail or engaging in chat sessions. What's the difference Between an Intranet and the Internet? There's one major distinction between an intranet and the Internet: The Internet is an open, public space, while an intranet is designed to be a private space. An intranet may b