sql interview question part 8

20
KAASHIV INFOTECH The Asia, India, Tamil Nadu Book Of Record Holders SQL SERVER –Booklet 8 - Gives you the interview tips in SQL Server SQL SERVER Interview Questions- 2014

Upload: kaashiv1

Post on 27-Jun-2015

137 views

Category:

Education


0 download

DESCRIPTION

Learn about SQL Server Interview Questions for further carrier development.

TRANSCRIPT

Page 1: Sql interview question part 8

KAASHIV INFOTECH

The Asia, India, Tamil Nadu Book Of Record Holders

SQL SERVER –Booklet 8- Gives you the interview tips in SQL Server

SQL SERVER Interview Questions-2014

Page 2: Sql interview question part 8

KAASHIV INFOTECH

Welcomes you to the Expert Voice Corner

Mr.J.Venkatesan PrabuVenkatesan Prabu Jayakantham (venkat) has more than 8 years experience in the Microsoft Technologies such as VB.Net, ASP.Net, C#.net, SSIS, SSAS, ADO.Net, etc., He is the Managing Director of KAASHIVINFOTECH (http://www.kaashivinfotech.com/),a software company in Chennai. Before that, he worked in HCL Technologies (India and Australia) for six years as Project Lead. As a service motive, Venkat contributed more than 700 articles which is read by the developers in 170 countries (400 developers per day) (http://venkattechnicalblog.blogspot.com/). Aligned with KaaShiv InfoTech’s mission,he met more than 20,000 young minds and spreaded Microsoft Technologies / Career guidance programs. Venkat won many awards in his career, which includes Prestigious Microsoft MVP (Most Valuable Professional) award for the years 2008,2009,2010,2011,2012,2013 and won many awards. List of other awards in his career,

Page 3: Sql interview question part 8

Microsoft certified Smart .Net Candidate in 2004

Most valuable member for dotnetspider site in 2007

HCL SQL Subject Matter expert (SME - SQL Server) for the year

(2008,2009)

HCL Special contribution award winner on Dotnet skills for year(2008)

HCL SQL Knowledge Champion for the year 2009

Mind Cracker MVP on SQLServer –2010 for the year 2010,2011

INETA champion - Gold Member – 2010 for the year 2010 HCL Service

Contribution Award for the year 2010

Leading Lights "Rising Star" award from Common Wealth Bank,

Australia for the year 2010

TECHNICAL CERTIFICATION

Cisco certified Network Associate (CCNA) – 2004

Microsoft Certified Application Developer (MCAD) – 2005

Page 4: Sql interview question part 8

ACKNOWLEDGEMENT

I would like to thank my family members for their support and encouragement. Without their support it would be impossible for me to publish this e-book. I would also like to thank my KaaShiv InfoTech team for their support to publish this e-book.

DISCLAIMER

All rights reserved. No part of this book may be copied, adapted, abridged or stored in any retrieval system, computer system, photographic or other system or transmitted in any form or by any means without the prior written permission of the copyright holders. Any breach will entail legal action and permission without further notice.    

Page 5: Sql interview question part 8

1. What is the difference between UNION and UNION ALL?UNION The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected.

UNION ALL The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all rows from all tables fitting your query specifics and combines them into a table.

2. What is B-Tree?The database server uses a B-tree structure to organize index information. B-Tree generally has following types of index pages or nodes:root node: A root node contains node pointers to branch nodes which can be only one.branch node: A branch node contains pointers to leaf nodes or other branch nodes which can be two or more.

Page 6: Sql interview question part 8

leaf nodes: A leaf node contains index items and horizontal pointers to other leaf nodes which can be many.

3. What is the difference between lock, block and deadlock? Lock: DB engine locks the rows/page/table to access the data which is worked upon according to the query.Block: When one process blocks the resources of another process then blocking happens. Blocking can be identified by usingSELECT * FROM sys.dm_exec_requests where blocked <> 0SELECT * FROM master..sysprocesses where blocked <> 0Deadlock: When something happens as follows: Error 1205 is reported by SQL Server for deadlock. 4.What is the meaning of lock escalation and why/how to stop this?When the DB engine would try to lock page first and then it escalates locks to page and then table. If we understand that whole table would be locked for the processing thenn this is better to use TABLOCK hint and get complete table blocked. This is a nice way to avoid the wastage of sql server DB engine processing for lock escalation. Somewhere you may also need to use TABLOCKX when you want an exclusive lock on the table in the query.

Page 7: Sql interview question part 8

5. How to truncate the log in sql server 2008?BACKUP LOG TestDB WITH TRUNCATE_ONLY is gone. SQL server doesn’t allow you to truncate the log now otherwise whole purpose of a DB is defeated.

6. What changes in the front end code is needed if mirroring is implemented for the high availability?You need to add only FAILOVER PARTNER information in your front end code. “Data Source=ServerA;Failover Partner=ServerB;Initial Catalog=AdventureWorks;Integrated Security=True;”.

7. Where does the copy job runs in the logshipping… Primary or secondary?Secondary server. This question is basically asked to find out whether you have a handson work on logshipping or not. I came through many cases when candidates have mentioned logshipping experience in many projects and they can’t answer this question. I never selected any candidate if he/she don’t answer these kind of small questions.

Page 8: Sql interview question part 8

8. What are the ways to find what code is running for any spid?Well there are many ways to do this.

1. find the spid which you want to analyze. An spid is assigned as soon as a client connection is established with the SQL server. To find the spid you can run any of the following command:

a) SP_WHO2 ‘ACTIVE’ — This will give you only active spids.b) SELECT * FROM sys.dm_exec_requests  

2. Get the spid from above two queries and use any of the following query to get what is happening behind that spid.

a) dbcc inputbuffer(<spid>)b) sql2005 and sql2008 – SELECT * FROM sys.dm_exec_sql_text(<sqlhandle of that spid>)c) sql2005 and sql2008 – SELECT * FROM fn_get_sql(<sqlhandle of that spid>)

Page 9: Sql interview question part 8

9. When you get following error? Error 3154: The backup set holds a backup of a database other than the existing database.The error comes when you are trying to restore the DB which already exists. Use WITH REPLACE option to restore the DB with a different name.

10.  Does DBCC CHECKDB requires DB to be in SINGLE_USER mode? Yes and No. This is tricky question. If you are using repair option with CHECKDB then you have to have the DB in single user mode. Following is the method to have your DB in a single user mode.Use mastergosp_dboption dbname, single, trueFollowing is the error which you get when you run the DBCC CHECKDB with repair option w\o having the DB in single user mode.

Page 10: Sql interview question part 8

11. How to view the error log for any specific instance?There are many ways but I prefer following method. Take a scenario when you want to find the error log when the DB was put in a single user mode.CREATE TABLE #Errorlog (Logdate Datetime, Processinfo VARCHAR(20),Text VARCHAR(2000))

INSERT INTO #ErrorlogEXEC xp_readerrorlogSELECT * FROM #ErrorlogWHERE Text Like ‘%SINGLE%USER%’12. What does the NOLOCK query hint do?Table hints allow you to override the default behavior of the query optimizer for statements. They are specified in the FROM clause of the statement. While overriding the query optimizer is not always suggested, it can be useful when many users or processes are touching data.

Page 11: Sql interview question part 8

The NOLOCK query hint is a good example because it allows you to read data regardless of who else is working with the data; that is, it allows a dirty read of data -- you read data no matter if other users are manipulating it. A hint like NOLOCK increases concurrency with large data stores.SELECT * FROM table_name (NOLOCK)

13.  What are the new features in SQL Server 2005 when compared to SQL Server 2000?There are quite a lot of changes and enhancements in SQL Server 2005. Few of them are listed here :Database PartitioningDynamic Management ViewsSystem Catalog ViewsResource DatabaseDatabase SnapshotsSQL Server Integration ServicesSupport for Analysis Services on a a Failover Cluster.Profiler being able to trace the MDX queries of the Analysis Server.

Page 12: Sql interview question part 8

Peer-toPeer ReplicationDatabase Mirroring

14. What are the High-Availability solutions in SQL Server and differentiate them briefly.

Failover Clustering, Database Mirroring, Log Shipping and Replication are the High-Availability features available in SQL Server.

15. How do you troubleshoot errors in a SQL Server Agent Job?

Inside SSMS, in Object explorer under SQL Server Agent look for Job Activity Monitor. The job activity monitor displays the current status of all the jobs on the instance. Choose the particular job which failed, right click and choose view history from the drop down menu. The execution history of the job is displayed and you may choose the execution time (if the job failed multiple times during the same day). There would information such as the time it took to execute that Job and details about the error occurred.

Page 13: Sql interview question part 8

KaaShiv InfoTech Offers Best Inpant Training in Chennai. 

The training at KAASHIV INFOTECH focus on developing the technical oriented concepts that turn graduates into employable assets. Handled only by professionals from MNC companies, we know how to equip you with strong technologies fundamentals.

INPLANT TRAINING SCHEDULE FOR CSE/IT/MCA STUDENTS

Day Programme

 Day 1 BigData (Practical Demos)

Day 2Windows 8 App Development (Practical Demos)

Day 3Ethical Hacking (Facebook Hack,Server/Website Hacking(20 Attacks)

Day 4Cloud Computing (Live Server Demo,Live Pjt Implementation)

Day 5CCNA (-Networking-Router Configurations Practical Demo)

Page 14: Sql interview question part 8

INPLANT TRAINING SCHEDULE FOR ELECTRONIC/ELECTRICAL/EIE STUDENTS:

Day Programme

Day 1 Embedded System  (Embedded Program Designing ,Chip Burning)

Day 2Wireless System  (Device Designing,Controlling Fans with Wireless Sensors)

Day 3 CCNA  (-Networking-Router Configurations Practical Demo)

Day 4Ethical Hacking  (Facebook Hack,Server/Website Hacking(20 Attacks)

Day 5Matlab  (Capture Image,Processing, Animate Images-Practical Demos)

Page 15: Sql interview question part 8

MECHANICAL/CIVIL INPLANT TRAINING SCHEDULE:

Day Programme

Day 1 Aircraft Designing

Day 2 Vehicle Movement in Airports

Day 3 3D Packaging Designs

Day 4 3D Modeling

Day 5 3D Window Shading

Page 16: Sql interview question part 8

Tags: inplanttraining in chennai,Best inplanttraining Program in Chennai Anna Nagar,Best and Effective inplanttraining Program in Chennai at Anna Nagar ,inplanttraining Program for Engineering Students , inplanttraining Program for Arts and Science Students , inplanttraining Program for BE Students , inplanttraining Program for Information Technology Students ,inplanttraining Program in Chennai , Best and Effective inplanttraining Program in Chennai,Best and good inplanttraining Program in Chennai,inplanttraining Program for Computer Science Students, inplanttraining Program for Electronics and Communication Students,inplanttraining Program for Electrical and Electronics Students , inplanttraining Program for Engineering Studentsin anna nagar , inplanttraining Program for Arts and Science Students in anna nagar,Effective inplanttraining Program,Effective and Free inplanttraining Program,best inplanttraining in chennai near rountana,best inplanttraining for engineering students in chennai,best inplanttraining in anna nagar,inplanttraining for arts and science students in tamil nadu,best inplanttraining for arts and science students in anna nagar near rountana,best inplanttraining for ug graduates,best inplanttraining for pg graduates,best inplanttraining for b.e/b.tech students,best inplanttraining for ug graduates in chennai,best inplanttraining for ug graduates in anna nagar,best inplanttraining for ug graduates in tamil nadu,best inplanttraining for pg graduates in chennai,

Page 17: Sql interview question part 8

best inplanttraining for pg graduates in anna nagar,best inplanttraining for pg graduates in tamil nadu,inplanttraining for cse students,inplanttraining for it students,inplanttraining for ece students,inplanttraining for eee students,inplanttraining on android in chennai,inplanttraining on java in chennai,inplanttraining on embedded systems in chennai,inplanttraining on matlab in chennai,inplanttraining on .net in chennai,inplanttraining on android in anna nagar,inplanttraining on java in anna nagar,inplanttraining on embedded systems in anna nagar,inplanttraining on matlab in anna nagar,inplanttraining on .net in anna nagar,best summer inplanttraining for arts and science ug graduates in chennai,best summer inplanttraining for arts and science pg graduates in chennai,best summer inplanttraining for engineering ug graduates in chennai,best summer inplanttraining for engineering pg graduates in chennai,best summer inplanttraining for arts and science ug graduates in anna nagar,best summer inplanttraining for arts and science pg graduates in anna nagar,best summer inplanttraining for engineering ug graduates in anna nagar,best summer inplanttraining for engineering pg graduates in anna nagar,best inplanttraining for mba graduates in chennai,best inplanttraining fo mca graduates in chennai,best inplanttraining for mba graduates in anna nagar,best inplanttraining for mca graduates in anna nagar,best summer inplanttraining for mba graduates in chennai,best summer inplanttraining for mca graduates in chennai,best summer inplanttraining for mba graduates in anna nagar, best summer inplanttraining for mba graduates near rountana,best summer inplanttraining for mca graduates near rountana

Page 18: Sql interview question part 8

Address: KAASHIV INFO TECHShivanantha Building,X41, 5th Floor,2nd Avenue,(Near Ayyappan Temple)Anna Nagar, Chennai = 600040.Send Us Your Request Email To [email protected],[email protected],[email protected] Number : 9840678906 ;; 9003718877 ;; 9962345637 ;

Visit our other websites:http://inplanttrainingchennai.com/ - Inplant Training Portalhttp://inplanttrainingchennai.com/ - Internship Portaljobsanddumps.com – Job Portalhttps://plus.google.com/u/0/108546120202591604585 https://plus.google.com/u/0/b/110228862465265998202/dashboard/overview

https://plus.google.com/u/0/b/117408505876070870512/dashboard/overview

Page 19: Sql interview question part 8

https://plus.google.com/u/0/b/104468163439231303834/dashboard/overview https://plus.google.com/u/0/b/117640664472494971423/dashboard/overview

KaaShiv InfoTech Facebook Page https://www.facebook.com/KaaShivInfoTech Inplant Training Program in Chennai https://www.facebook.com/pages/Inplant-Training-Program-in-Chennai/1402097696706380

Internship in Chennai

https://www.facebook.com/pages/Internship-in-Chennai-KaaShiv/1446147235603704

Page 20: Sql interview question part 8

Inplant Training

https://www.facebook.com/pages/Inplant-Training/256116284550327