• Home
  • SQL Server
    • Articles
    • T-SQL Puzzles
    • Output Puzzles
    • Interview Questions
    • Performance Tuning
    • SQL SERVER On Linux
    • Resources
  • SSRS
    • SSRS Articles
    • Interview Questions
  • SSAS
    • SSAS Articles
    • DAX
  • SQL Puzzles
  • Interview Questions
    • SQL Interview Questions
    • Data Interview Questions
  • Python Interview Puzzles
  • New Features(SQL SERVER)
    • SQL SERVER 2017
    • SQL SERVER 2016
    • SQL SERVER On Linux
  • Social
    • Expert Exchange
      • Top Expert in SQL
      • Yearly Award
      • Certifications
      • Achievement List
      • Top Expert of the Week
    • HackerRank (SQL)
    • StackOverflow
    • About Me
      • Contact Me
      • Blog Rules

Improving my SQL BI Skills

Improving my SQL BI Skills

Daily Archives: May 13, 2015

SQL SERVER Interview Questions & Answers – SET 1 (50 Questions)

13 Wednesday May 2015

Posted by Pawan Kumar Khowal in Download SQL Interview Q's, SQL Server Interview Questions

≈ 1 Comment

Tags

Advanced SQL interview questions, Advanced SQL Queries, Advanced SQL tutorial, Advanced SQL tutorial pdf, Can we use GUID as Primary key in a table?, Could you please provide SQL 2014 New Features in DB Engine, Difference between Latch and Lock, difference between Unique Index and Unique Constraint?, Difficult SQL Interview Questions, Download SQL Interview Questions, Download SQL Questions, Download SQL Server Interview Question in PDF, Download SQL SERVER Interview questions, Download SQL Server Interview questions and answers, download sql server interview questions and answers pdf, download sql server interview questions by Pawan Khowal, download sql server interview questions by Pawan Kumar, download sql server interview questions by Pawan Kumar Khowal, Download T-SQL Interview Questions, Free Download SQL SERVER Interview questions, In which scenarios we should not use CTE's, Interview Qs.SQL SERVER Questions, Interview Questions on SQL, InterviewQuestions, InterviewQuestions for SQL, Joins Puzzle, Puzzles, Queries for SQL Interview, SQL, SQL 2012, SQL 2014, SQL 2014 Interview Questions, SQL Common Interview Questions, SQL Common Interview Questions and answers, SQL FAQ, SQL FAQs, SQL Interview Q & A, SQL Interview Questions, SQL Joins, SQL Queries, SQL Queries asked in interviews, SQL Questions, SQL Server, SQL Server - General Interview Questions and Answers, SQL Server developer Interview questions and answers, SQL Server developer Interview questions with answers, SQL SERVER Interview questions, SQL SERVER Interview questions & Answers, SQL Server Interview questions and answers, SQL Server Interview Questions and Answers - Free PDF, SQL SERVER Interview questions and answers for experienced, sql server interview questions and answers for net developers, SQL SERVER Interview questions for experienced, SQL SERVER Interview questions pdf, SQL SERVER Tips, SQL SERVER Tricky questions, SQL Skills, SQL Tips & Tricks, SQL Tips and Tricks, SQL Tricks, SQL Tricky question, SQL Tutorial, SQLSERVER, T-SQL, T-SQL Interview questions, T-SQL Programming, T-SQL Server Interview Questions, T-SQL Tutorial, TOP 100 SQL SERVER INTERVIEW QUESTIONS, Top 50 SQL Server Questions & Answers, Tough PL SQL Interview Questions, Tough SQL Interview Questions, Tough SQL Queries, Tough SQL Queries Interview Questions, Tough SQL Questions, Tricky SQL Interview Questions, Tricky SQL Interview Questions and answers, Tricky SQL Queries for Interview, Tricky SQL SERVER Interview Questions and answers, TSQL, TSQL Interview questions, TSQL Queries, types of physical joins in SQL Server, What are RED Flags in SQL Server and what is there usage?, What are statistics? Where they are used and how to check statistics, What are the types of Fragmentations, What is a Latch in SQL Server, What is the difference between Unique Index and Unique Constraint?


SQL SERVER Interview Questions & Answers – SET 1 (50 Questions & Answers)

Download – Pawan Kumar Khowal – SQL SERVER Interview Questions with Answers

PAGE – 1

NEXT

Question 1. What are statistics? Where they are used and how to check statistics.

Answer. 
SQL server optimizer uses the statistics to choose the best query plan. If the statistics are incorrect (means outdated), then there are chances that SQL server engine might choose an incorrect query plan. You can check statistics by using below command –


DBCC SHOW_STATISTICS('TestRIDInxs','Ix_Index')
Table Name – TestRIDInxs
Index Name - 'Ix_Index

Output of the above query is given below-

Statistics

_______________________________________________________________

Question 2. What are the types of Fragmentations

Answer –Pawan Kumar Khowal – SQL SERVER Interview Questions with Answers
Fragmentation means the data is NOT stored contiguously on disk. There are two types of Fragmentation. There are two  kinds of fragmentation-

  1. Logical fragmentation – Here the next logical page as determined by the index order is not the next physical page in the data file.
  2. Physical (or internal) fragmentation – Here the space is being wasted on index pages. The rows inside the page are not contiguous.

These can both affect query performance, as well as the expense of having to do the page split in the first place.

If you want to understand this in detail please visit – http://www.sqlskills.com/blogs/paul/category/fragmentation/

________________________________________________________________

Question 3. Can we use GUID as Primary key in a table?

Answer – We can use GUID as primary key in a table But we should NOT. It will create fragmentation issue.

For details please visit – https://msbiskills.com/2015/04/09/guid-causes-fragmentation-in-clustered-indexes/

________________________________________________________________________

Question 4. What is the difference between Unique Index and Unique Constraint?

Answer –
A unique index is just an index, whereas a unique constraint is a unique index that’s listed as a constraint object in the database. In the sysobjects table, the unique constraint will have an xtype value of “UQ.”. Unique key basically creates a unique index internally to maintain uniqueness.

Note – Unique index and a unique constraint have same effect on a table. Performance is also same for both. Command to create unique index and unique constraint are given below.


--Command to add Index
CREATE UNIQUE INDEX Ix_Indexer ON TestRIDInxs(EId)

--Command to add constraint
ALTER TABLE TestRIDInxs
  ADD CONSTRAINT UNQ_Constraint UNIQUE (EId)

Now if you check the table definition (shortcut – ALT+F1) it will give you below information-

UniqueIndex

________________________________________________________________

Question 5. What are RED Flags in SQL Server and what is there usage?

Answer – 
There are some flags in execution plan which normally reduces the performance of the query. Some of them are given below.

  1. High Percentage Operations
  2. Table Scans, Index Scans, Clustered Index Scans
  3. Spools
  4. Parallelism operations
  5. Warnings
  6. Thick Arrows
  7. Hash Joins
  8. Bookmark Lookups
  9. Sorting

For details please visit below-

–http://www.sqlservercentral.com/articles/Performance+Tuning/sevenshowplanredflags/1425/
– http://www.slideshare.net/kkline84/ten-query-tuning-techniques-every-sql-server-programmer-should-know

___________________________________________________________________________

Question 6. What are the types of physical joins in SQL Server? What are the different join operators in SQL Server?

Answer –
There are three types of physical joins given below-

Nested Loop

  • Used when one table is significantly small
  • The larger table has an index which allows seeking it using the join key

Merge Join

  • Both inputs are sorted on the join key
  • An equality operator is used
  • Excellent for very large tables

Hash Match

  • If the SQL Server can’t use any of the above mentioned joins then it will use Hash Match join.
  • Uses a hash table and a dynamic hash match function to match rows

For details please visit below links-
Nested Loop Joins: http://blogs.msdn.com/b/craigfr/archive/2006/07/19/671712.aspx Merge Joins: http://blogs.msdn.com/b/craigfr/archive/2006/08/03/merge-join.aspx
Hash Joins: http://blogs.msdn.com/b/craigfr/archive/2006/08/10/687630.aspx

______________________________________________________________

Question 7. What is a Latch in SQL Server?

Latches perform the task of thread synchronization. For example, if a thread is reading a page from disk and creating a memory structure to contain it, it will create one or more Latches to prevent corruption of these structures. Once the operation is complete, the Latches will be released and other threads will be able to access that page and memory structure again. For the most part, latches are transient, taking a few milliseconds to complete.

A latch can be defined as an object that ensures data integrity on other objects in SQL Server memory, particularly pages. They are a logical construct that ensures controlled access to a resource and isolationism when required for pages in use. In contrast to locks, latches are an internal SQL Server mechanism that isn’t exposed outside the SQLOS. They come in many different types but can be split into roughly two classes – buffer latches, and non-buffer latches.

A latch is a lightweight synchronization object used by the Storage Engine to protect memory structures used internally by SQL Server. A latch is nothing more than a so-called Critical Section in multi-threaded programming – with some differences.

______________________________________________________________

Question 8. Difference between Latch and Lock.

Answer-
Latches are internal to the SQL Server engine. They are used to provide memory consistency. Locks are used by SQL Server to provide logical transactional consistency.

For details please visit –

http://www.sqlskills.com/blogs/paul/category/latches/
http://www.sqlskills.com/blogs/paul/category/locking/

_____________________________________________________________

Question 9. Could you please provide SQL 2014 New Features in DB Engine?

Answer-
New features in SQL 2014 Db engine are given below –

  1. In-Memory OLTP (In-Memory Optimization)
  2. SQL Server Data Files in Windows Azure
  3. Host a SQL Server Database in a Windows Azure Virtual Machine
  4. Backup and Restore Enhancements

◾SQL Server Backup to URL
◾SQL Server Managed Backup to Windows Azure
◾Encryption for Backups

  1. New Design for Cardinality Estimation
  2. Delayed Durability
  3. Updateable Column Store Indexes
  4. Incremental Statistics & Partition Enhancement
  5. Buffer Pool Extension to Solid State Drives (SSDs).
  6. Managing Locks in Online Index
  7. Always On Improvements
  8. Resource Governor Enhancements

For details please refer – https://pawankkmr.wordpress.com/2015/04/08/sql-server-2014-new-features/

Question 10. In which scenarios we should not use CTE’s.

Answer-
We should not use CTE’s for large tables. A CTE can be used:

  • For recursion
  • Substitute for a view when the general use of a view is not required; that is, you do not have to store the definition in metadata.

Reference the resulting non large table multiple times in the same statement.

NEXT

Share this

  • LinkedIn
  • Facebook
  • Twitter
  • WhatsApp
  • Email

Blog Stats

  • 1,074,528 hits

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 1,131 other subscribers

Pawan Khowal

502 SQL Puzzles with answers

Achievement - 500 PuzzlesJuly 18, 2018
The big day is here. Finally presented 500+ puzzles for SQL community.

200 SQL Server Puzzle with Answers

The Big DayAugust 19, 2016
The big day is here. Completed 200 SQL Puzzles today

Archives

May 2015
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031
« Apr   Jun »

Top Articles

  • pawankkmr.wordpress.com/2…
  • pawankkmr.wordpress.com/2…
  • pawankkmr.wordpress.com/2…
  • pawankkmr.wordpress.com/2…
  • pawankkmr.wordpress.com/2…

Archives

  • October 2020 (29)
  • September 2018 (2)
  • August 2018 (6)
  • July 2018 (25)
  • June 2018 (22)
  • May 2018 (24)
  • April 2018 (33)
  • March 2018 (35)
  • February 2018 (53)
  • January 2018 (48)
  • December 2017 (32)
  • November 2017 (2)
  • October 2017 (20)
  • August 2017 (8)
  • June 2017 (2)
  • March 2017 (1)
  • February 2017 (18)
  • January 2017 (2)
  • December 2016 (5)
  • November 2016 (23)
  • October 2016 (2)
  • September 2016 (14)
  • August 2016 (6)
  • July 2016 (22)
  • June 2016 (27)
  • May 2016 (15)
  • April 2016 (7)
  • March 2016 (5)
  • February 2016 (7)
  • December 2015 (4)
  • October 2015 (23)
  • September 2015 (31)
  • August 2015 (14)
  • July 2015 (16)
  • June 2015 (29)
  • May 2015 (25)
  • April 2015 (44)
  • March 2015 (47)
  • November 2012 (1)
  • July 2012 (8)
  • September 2010 (26)
  • August 2010 (125)
  • July 2010 (2)

Article Categories

  • Analysis Services (6)
    • DAX (6)
  • Data (2)
    • Data warehousing (2)
  • Integration Services (2)
  • Magazines (3)
  • Python (29)
  • Reporting Services (4)
  • SQL SERVER (820)
    • Download SQL Interview Q's (212)
    • SQL Concepts (323)
    • SQL Performance Tuning (155)
    • SQL Puzzles (331)
    • SQL SERVER 2017 Linux (6)
    • SQL Server Interview Questions (308)
    • SQL SERVER Puzzles (332)
    • T SQL Puzzles (547)
    • Tricky SQL Queries (439)
  • UI (30)
    • ASP.NET (5)
    • C# (13)
    • CSS (9)
    • OOPS (3)
  • Uncategorized (5)

Recent Posts

  • Python | The Print and Divide Puzzle October 30, 2020
  • Python | Count consecutive 1’s from a list of 0’s and 1’s October 30, 2020
  • Python | How to convert a number into a list of its digits October 26, 2020
  • Python | Validate an IP Address-IPV6(Internet Protocol version 6) October 26, 2020
  • Python | Print the first non-recurring element in a list October 26, 2020
  • Python | Print the most recurring element in a list October 26, 2020
  • Python | Find the cumulative sum of elements in a list October 26, 2020
  • Python | Check a character is present in a string or not October 26, 2020
  • Python | Check whether a string is palindrome or not October 26, 2020
  • Python | Find the missing number in the array of Ints October 26, 2020
  • Python | How would you delete duplicates in a list October 26, 2020
  • Python | Check whether an array is Monotonic or not October 26, 2020
  • Python | Check whether a number is prime or not October 26, 2020
  • Python | Print list of prime numbers up to a number October 26, 2020
  • Python | Print elements from odd positions in a list October 26, 2020
  • Python | Print positions of a string present in another string October 26, 2020
  • Python | How to sort an array in ascending order October 26, 2020
  • Python | How to reverse an array October 26, 2020
  • Python | Find un-common words from two strings October 26, 2020
  • Python | How to convert a string to a list October 26, 2020
  • Python | Find unique words from a string October 26, 2020
  • Python | Calculate average word length from a string October 26, 2020
  • Python | Find common words from two strings October 26, 2020
  • Python | Find the number of times a substring present in a string October 26, 2020
  • Python | Find maximum value from a list October 26, 2020
  • Python | How to find GCF of two numbers October 26, 2020
  • Python | How to find LCM of two numbers October 26, 2020
  • Python | How to convert a list to a string October 26, 2020
  • Python | Replace NONE by its previous NON None value October 26, 2020
  • Microsoft SQL Server 2019 | Features added to SQL Server on Linux September 26, 2018

Create a website or blog at WordPress.com

  • Follow Following
    • Improving my SQL BI Skills
    • Join 231 other followers
    • Already have a WordPress.com account? Log in now.
    • Improving my SQL BI Skills
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...
 

You must be logged in to post a comment.