SlideShare a Scribd company logo
1 of 103
Download to read offline
hirist 
.com 
www.hirist.com 
SQL 
TOP 100 
INTERVIEW QUESTIONS & ANSWERS
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisDBMS? 
2 
QUESTION 
ADatabaseManagementSystem(DBMS)isaprogramthatcontrolscreation,maintenanceanduseofadatabase. DBMScanbetermedasFileManagerthatmanagesdatainadatabaseratherthansavingitinfilesystems. 
ANSWER 
QUESTION 1
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisRDBMS? 
3 
QUESTION 
RDBMSstandsforRelationalDatabaseManagementSystem.RDBMSstorethedataintothecollectionoftables, whichisrelatedbycommonfieldsbetweenthecolumnsofthetable.Italsoprovidesrelationaloperatorstomanipulatethedatastoredintothetables. 
Example:SQLServer. 
ANSWER 
QUESTION 2
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisSQL? 
4 
QUESTION 
SQLstandsforStructuredQueryLanguage,anditisusedtocommunicatewiththeDatabase.Thisisastandardlanguageusedtoperformtaskssuchasretrieval,updation,insertionanddeletionofdatafromadatabase. 
StandardSQLCommandsareSelect. 
ANSWER 
QUESTION 3
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisaDatabase? 
5 
QUESTION 
Databaseisnothingbutanorganizedformofdataforeasyaccess,storing,retrievalandmanagingofdata.Thisisalsoknownasstructuredformofdatawhichcanbeaccessedinmanyways. 
Example:SchoolManagementDatabase,BankManagementDatabase. 
ANSWER 
QUESTION 4
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhataretablesandFields? 
6 
QUESTION 
AtableisasetofdatathatareorganizedinamodelwithColumnsandRows.Columnscanbecategorizedasvertical,andRowsarehorizontal.Atablehasspecifiednumberofcolumncalledfieldsbutcanhaveanynumberofrowswhichiscalledrecord. 
Example:. 
Table:Employee. 
Field:EmpID,EmpName,DateofBirth. 
Data:201456,David,11/15/1960. 
ANSWER 
QUESTION 5
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisaprimarykey? 
7 
QUESTION 
Aprimarykeyisacombinationoffieldswhichuniquelyspecifyarow.Thisisaspecialkindofuniquekey,andithasimplicitNOTNULLconstraint.Itmeans,PrimarykeyvaluescannotbeNULL. 
ANSWER 
QUESTION 6
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisauniquekey? 
8 
QUESTION 
AUniquekeyconstraintuniquelyidentifiedeachrecordinthedatabase.Thisprovidesuniquenessforthecolumnorsetofcolumns. 
APrimarykeyconstrainthasautomaticuniqueconstraintdefinedonit.Butnot,inthecaseofUniqueKey. 
Therecanbemanyuniqueconstraintdefinedpertable,butonlyonePrimarykeyconstraintdefinedpertable. 
ANSWER 
QUESTION 7
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisaforeignkey? 
9 
QUESTION 
Aforeignkeyisonetablewhichcanberelatedtotheprimarykeyofanothertable.Relationshipneedstobecreatedbetweentwotablesbyreferencingforeignkeywiththeprimarykeyofanothertable. 
ANSWER 
QUESTION 8
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatarethetypesofjoinandexplaineach? 
10 
QUESTION 
Therearevarioustypesofjoinwhichcanbeusedtoretrievedataanditdependsontherelationshipbetweentables. 
InnerJoin:Innerjoinreturnrowswhenthereisatleastonematchofrowsbetweenthetables. 
RightJoin:RightjoinreturnrowswhicharecommonbetweenthetablesandallrowsofRighthandsidetable. Simply,itreturnsalltherowsfromtherighthandsidetableeventhoughtherearenomatchesinthelefthandsidetable. 
LeftJoin:LeftjoinreturnrowswhicharecommonbetweenthetablesandallrowsofLefthandsidetable.Simply,itreturnsalltherowsfromLefthandsidetableeventhoughtherearenomatchesintheRighthandsidetable. 
FullJoin:Fulljoinreturnrowswhentherearematchingrowsinanyoneofthetables.Thismeans,itreturnsalltherowsfromthelefthandsidetableandalltherowsfromtherighthandsidetable. 
ANSWER 
QUESTION 9
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Explainanouterjoin? 
11 
QUESTION 
Anouterjoinincludesrowsfromtableswhentherearenomatchingvaluesinthetables. 
ANSWER 
QUESTION 10
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisnormalization? 
12 
QUESTION 
Normalizationistheprocessofminimizingredundancyanddependencybyorganizingfieldsandtableofadatabase.ThemainaimofNormalizationistoadd,deleteormodifyfieldthatcanbemadeinasingletable. 
ANSWER 
QUESTION 11
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisDenormalization? 
13 
QUESTION 
DeNormalizationisatechniqueusedtoaccessthedatafromhighertolowernormalformsofdatabase.Itisalsoprocessofintroducingredundancyintoatablebyincorporatingdatafromtherelatedtables. 
ANSWER 
QUESTION 12
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatareallthedifferentnormalizations? 
14 
QUESTION 
Thenormalformscanbedividedinto4forms,andtheyareexplainedbelow-. 
FirstNormalForm(1NF):Thisshouldremovealltheduplicatecolumnsfromthetable.Creationoftablesfortherelateddataandidentificationofuniquecolumns. 
SecondNormalForm(2NF):Meetingallrequirementsofthefirstnormalform.PlacingthesubsetsofdatainseparatetablesandCreationofrelationshipsbetweenthetablesusingprimarykeys. 
ThirdNormalForm(3NF):Thisshouldmeetallrequirementsof2NF.Removingthecolumnswhicharenotdependentonprimarykeyconstraints. 
FourthNormalForm(4NF):Meetingalltherequirementsofthirdnormalformanditshouldnothavemulti- valueddependencies. 
ANSWER 
QUESTION 13
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisanIndex?Whatareallthedifferenttypesofindexes? 
15 
QUESTION 
Anindexisperformancetuningmethodofallowingfasterretrievalofrecordsfromthetable.Anindexcreatesanentryforeachvalueanditwillbefastertoretrievedata. 
Thisindexingdoesnotallowthefieldtohaveduplicatevaluesifthecolumnisuniqueindexed.Uniqueindexcanbeappliedautomaticallywhenprimarykeyisdefined. 
ClusteredIndex:Thistypeofindexreordersthephysicalorderofthetableandsearchbasedonthekeyvalues. Eachtablecanhaveonlyoneclusteredindex. 
NonClusteredIndex:NonClusteredIndexdoesnotalterthephysicalorderofthetableandmaintainslogicalorderofdata.Eachtablecanhave999nonclusteredindexes. 
ANSWER 
QUESTION 14
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisarelationshipandwhatarethey? 
16 
QUESTION 
DatabaseRelationshipisdefinedastheconnectionbetweenthetablesinadatabase.Therearevariousdatabasingrelationships,andtheyareasfollows:. OnetoOneRelationship. OnetoManyRelationship. ManytoOneRelationship. Self-ReferencingRelationship. 
ANSWER 
QUESTION 15
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisaquery? 
17 
QUESTION 
ADBqueryisacodewritteninordertogettheinformationbackfromthedatabase.Querycanbedesignedinsuchawaythatitmatchedwithourexpectationoftheresultset.Simply,aquestiontotheDatabase. 
ANSWER 
QUESTION 16
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatissubquery?Whatarethetypesofsubquery? 
18 
QUESTION 
Asubqueryisaquerywithinanotherquery.Theouterqueryiscalledasmainquery,andinnerqueryiscalledsubquery.SubQueryisalwaysexecutedfirst,andtheresultofsubqueryispassedontothemainquery. 
Therearetwotypesofsubquery–CorrelatedandNon-Correlated. 
Acorrelatedsubquerycannotbeconsideredasindependentquery,butitcanreferthecolumninatablelistedintheFROMthelistofthemainquery. 
ANon-Correlatedsubquerycanbeconsideredasindependentqueryandtheoutputofsubqueryaresubstitutedinthemainquery. 
ANSWER 
QUESTION 17
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisatrigger? 
19 
QUESTION 
ADBtriggerisacodeorprogramsthatautomaticallyexecutewithresponsetosomeeventonatableorviewinadatabase.Mainly,triggerhelpstomaintaintheintegrityofthedatabase. 
Example:Whenanewstudentisaddedtothestudentdatabase,newrecordsshouldbecreatedintherelatedtableslikeExam,ScoreandAttendancetables. 
ANSWER 
QUESTION 18
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatarethetypesofTriggers? 
20 
QUESTION 
Therearefourtypesoftriggersandtheyare: 
•Insert 
•Delete 
•Update 
•Insteadof 
ANSWER 
QUESTION 19
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisthedifferencebetweenDELETETRUNCATEandDROPcommands? 
21 
QUESTION 
DELETEcommandisusedtoremoverowsfromthetable,andWHEREclausecanbeusedforconditionalsetofparameters.CommitandRollbackcanbeperformedafterdeletestatement. 
TRUNCATEremovesallrowsfromthetable.Truncateoperationcannotberolledback. 
Dropcommandisusedtodropthetableorkeyslikeprimary,foreignfromatable. 
ANSWER 
QUESTION 20
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisdataIntegrity? 
22 
QUESTION 
DataIntegritydefinestheaccuracyandconsistencyofdatastoredinadatabase.Itcanalsodefineintegrityconstraintstoenforcebusinessrulesonthedatawhenitisenteredintotheapplicationordatabase. 
ANSWER 
QUESTION 21
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatiscollation? 
23 
QUESTION 
Collationisdefinedassetofrulesthatdeterminehowcharacterdatacanbesortedandcompared.ThiscanbeusedtocompareAand,otherlanguagecharactersandalsodependsonthewidthofthecharacters. 
ASCIIvaluecanbeusedtocomparethesecharacterdata. 
ANSWER 
QUESTION 22
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
AdvantagesandDisadvantagesofStoredProcedure? 
24 
QUESTION 
Storedprocedurecanbeusedasamodularprogramming–meanscreateonce,storeandcallforseveraltimeswheneverrequired.Thissupportsfasterexecutioninsteadofexecutingmultiplequeries.Thisreducesnetworktrafficandprovidesbettersecuritytothedata. 
DisadvantageisthatitcanbeexecutedonlyintheDatabaseandutilizesmorememoryinthedatabaseserver. 
ANSWER 
QUESTION 23
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisSQLInjection? 
25 
QUESTION 
SQLInjectionisoneofthetechniquesusesbyhackerstohackawebsitebyinjectingSQLcommandsindatafields. 
ANSWER 
QUESTION 24
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisthedifferencebetweenaHAVINGCLAUSEandaWHERECLAUSE? 
26 
QUESTION 
Theyspecifyasearchconditionforagrouporanaggregate.ButthedifferenceisthatHAVINGcanbeusedonlywiththeSELECTstatement.HAVINGistypicallyusedinaGROUPBYclause.WhenGROUPBYisnotused, HAVINGbehaveslikeaWHEREclause.HavingClauseisbasicallyusedonlywiththeGROUPBYfunctioninaquerywhereasWHEREClauseisappliedtoeachrowbeforetheyarepartoftheGROUPBYfunctioninaquery. 
ANSWER 
QUESTION 25
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Howwouldapplydaterangefilter? 
27 
QUESTION 
a.Youcanusesimplecondition>=and<=orsimilarorusebetween/andbutthetrickistoknowyourexactdatatype. 
b.Sometimesdatefieldscontaintimeandthatiswherethequerycangowrongsoitisrecommendedtousesomedaterelatedfunctionstoremovethetimeissue.InSQLServercommonfunctiontodothatisdatedifffunction. 
c.Youalsohavetobeawareofdifferenttimezonesandservertimezone. 
d.Toincreasequeryperformanceyoumaystillwanttousebetweenhoweveryoushouldbeawareofproperformatyoushoulduseifnotitmightmisbehaveduringfiltering. 
ANSWER 
QUESTION 26
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisthedifferencebetweenJOINandUNION? 
28 
QUESTION 
SQLJOINallowsusto―lookup‖recordsonothertablebasedonthegivenconditionsbetweentwotables.Forexample,ifwehavethedepartmentIDofeachemployee,thenwecanusethisdepartmentIDoftheemployeetabletojoinwiththedepartmentIDofdepartmenttabletolookupdepartmentnames. 
UNIONoperationallowsustoadd2similardatasetstocreateresultingdatasetthatcontainsallthedatafromthesourcedatasets.Uniondoesnotrequireanyconditionforjoining.Forexample,ifyouhave2employeetableswithsamestructure,youcanUNIONthemtocreateoneresultsetthatwillcontainalltheemployeesfrombothofthetables. 
SELECT*FROMEMP1 
UNION 
SELECT*FROMEMP2; 
ANSWER 
QUESTION 27
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisthedifferenceamongUNION,MINUSandINTERSECT? 
29 
QUESTION 
UNIONcombinestheresultsfrom2tablesandeliminatesduplicaterecordsfromtheresultset. 
MINUSoperatorwhenusedbetween2tables,givesusalltherowsfromthefirsttableexcepttherowswhicharepresentinthesecondtable. 
INTERSECToperatorreturnsusonlythematchingorcommonrowsbetween2resultsets. 
ANSWER 
QUESTION 28
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisSelfJoinandwhyisitrequired? 
30 
QUESTION 
SelfJoinistheactofjoiningonetablewithitself.SelfJoinisoftenveryusefultoconvertahierarchicalstructureintoaflatstructure 
ANSWER 
QUESTION 29
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
HowcanwetransposeatableusingSQL(changingrowstocolumnorvice-versa)? 
31 
QUESTION 
TheusualwaytodoitinSQListouseCASEstatementorDECODEstatement. 
ANSWER 
QUESTION 30
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatarethedifferencesamongROWNUM,RANKandDENSE_RANK? 
32 
QUESTION 
ROW_NUMBERassignscontiguous,uniquenumbersfrom1..Ntoaresultset. 
RANKdoesnotassignuniquenumbers—nordoesitassigncontiguousnumbers.Iftworecordstieforsecondplace,norecordwillbeassignedthe3rdrankasnoonecameinthird,accordingtoRANK. 
DENSE_RANK,likeRANK,doesnotassignuniquenumbers,butitdoesassigncontiguousnumbers.Eventhoughtworecordstiedforsecondplace,thereisathird-placerecord. 
ANSWER 
QUESTION 31
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisadatabasetransaction? 
33 
QUESTION 
Databasetransactiontakedatabasefromoneconsistentstatetoanother.Attheendofthetransactionthesystemmustbeinthepriorstateiftransactionfailsorthestatusofthesystemshouldreflectthesuccessfulcompletionifthetransactiongoesthrough. 
ANSWER 
QUESTION 32
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatarepropertiesofatransaction? 
34 
QUESTION 
PropertiesofthetransactioncanbesummarizedasACIDProperties. 
1.Atomicity:Atransactionconsistsofmanysteps.Whenallthestepsinatransactiongetscompleted,itwillgetreflectedinDBorifanystepfails,allthetransactionsarerolledback. 
2.Consistency:Thedatabasewillmovefromoneconsistentstatetoanother,ifthetransactionsucceedsandremainintheoriginalstate,ifthetransactionfails. 
3.Isolation:Everytransactionshouldoperateasifitistheonlytransactioninthesystem 
4.Durability:Onceatransactionhascompletedsuccessfully,theupdatedrows/recordsmustbeavailableforallothertransactionsonapermanentbasis 
ANSWER 
QUESTION 33
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisaDatabaseLock?Whatarethetypeoflocks? 
35 
QUESTION 
Databaselocktellatransaction,ifthedataiteminquestionsiscurrentlybeingusedbyothertransactions. 
1.SharedLock:Whenasharedlockisappliedondataitem,othertransactionscanonlyreadtheitem,butcan'twriteintoit. 
2.ExclusiveLock:Whenaexclusivelockisappliedondataitem,othertransactionscan'treadorwriteintothedataitem. 
ANSWER 
QUESTION 34
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisaCompositeKey? 
36 
QUESTION 
ACompositeprimarykeyisatypeofcandidatekey,whichrepresentsasetofcolumnswhosevaluesuniquelyidentifyeveryrowinatable. 
Forexample-if"Employee_ID"and"EmployeeName"inatableiscombinedtouniquelyidentifiesarowitscalledaCompositeKey. 
ANSWER 
QUESTION 35
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisaCompositePrimaryKey? 
37 
QUESTION 
ACompositeprimarykeyisasetofcolumnswhosevaluesuniquelyidentifyeveryrowinatable.Whatitmeansisthat,tablewhichcontainscompositeprimarykeywillbeindexedbasedoncolumnsspecifiedintheprimarykey. ThiskeywillbereferredinForeignKeytables. 
Forexample-ifcombinedeffectofcolumns,"Employee_ID"and"EmployeeName"inatableisrequiredtouniquelyidentifiesarow,itscalledaCompositePrimaryKey.Inthiscase,boththecolumnswillberepresentedasprimarykey. 
ANSWER 
QUESTION 36
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
DefineSQLInsertStatement? 
38 
QUESTION 
SQLINSERTstatementisusedtoaddrowstoatable.Forafullrowinsert,SQLQueryshouldstartwith―insertinto―statementfollowedbytablenameandvaluescommand,followedbythevaluesthatneedtobeinsertedintothetable.Insertcanbeusedinseveralways: 
1.Toinsertasinglecompleterow 
2.Toinsertasinglepartialrow 
ANSWER 
QUESTION 37
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
DefineSQLUpdateStatement? 
39 
QUESTION 
SQLUpdateisusedtoupdatedatainaroworsetofrowsspecifiedinthefiltercondition. 
ThebasicformatofanSQLUPDATEstatementis,UpdatecommandfollowedbytabletobeupdatedandSETcommandfollowedbycolumnnamesandtheirnewvaluesfollowedbyfilterconditionthatdetermineswhichrowsshouldbeupdated. 
ANSWER 
QUESTION 38
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatarewildcardsusedindatabaseforPatternMatching? 
40 
QUESTION 
SQLLikeoperatorisuserforpatternmatching.SQL'Like'commandtakesmoretimetoprocess.Sobeforeusinglikeoperator,considersuggestionsgivenbelowonwhenandwheretousewildcardsearch. 
1)Don'toverusewildcards.Ifanothersearchoperatorwilldo,useitinstead. 
2)Whenyoudousewildcards,trynottousethematthebeginningofthesearchpattern,unlessabsolutelynecessary.Searchpatternsthatbeginwithwildcardsaretheslowesttoprocess. 
3)Paycarefulattentiontotheplacementofthewildcardsymbols.Iftheyaremisplaced,youmightnotreturnthedatayouintended 
ANSWER 
QUESTION 39
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisCrossJoin? 
41 
QUESTION 
CrossJoinwillreturnallrecordswhereeachrowfromthefirsttableiscombinedwitheachrowfromthesecondtable. 
ANSWER 
QUESTION 40
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisaview? 
42 
QUESTION 
Viewsarevirtualtables.Unliketablesthatcontaindata,viewssimplycontainqueriesthatdynamicallyretrievedatawhenused. 
ANSWER 
QUESTION 41
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisamaterializedview? 
43 
QUESTION 
Materializedviewsisalsoaviewbutarediskbased.Materializedviewsgetupdatedonspecificduration,baseupontheintervalspecifiedinthequerydefinition.Wecanindexmaterializedview. 
ANSWER 
QUESTION 42
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whataretheadvantagesanddisadvantagesofviewsinadatabase? 
44 
QUESTION 
Advantages: 
1.Viewsdoesn'tstoredatainaphysicallocation. 
2.Viewcanbeusetohidesomeofthecolumnsfromthetable 
3.ViewscanprovideAccessRestriction,sincedatainsertion,updateanddeletionisnotpossibleontheview. 
Disadvantages: 
1.Whenatableisdropped,associatedviewbecomeirrelevant. 
2.Sinceviewarecreatedwhenaqueryrequestingdatafromviewistriggered,itsbitslow 
3.Whenviewsarecreatedforlargetables,itoccupymorememory. 
ANSWER 
QUESTION 43
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhendoyouuseUPDATE_STATISTICScommand? 
45 
QUESTION 
Thiscommandisusedwhenalargeprocessingofdatahasoccurred.Ifanylargeamountofdeletions,anymodifications,orBulkCopyintothetableshasoccurred,ithastoupdatetheindexestotakethesechangesintoaccount.UPDATE_STATISTICSupdatestheindexesonthesetablesaccordingly. 
ANSWER 
QUESTION 44
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisanIDENTITYcolumnininsertstatements? 
46 
QUESTION 
IDENTITYcolumnisusedintablecolumnstomakethatcolumnasAutoincrementalnumberorasurrogatekey. 
ANSWER 
QUESTION 45
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
HowwillIretrieveallrecordsofemployment1thoseshouldnotbepresentnemployment2? 
47 
QUESTION 
(Select*fromemployment2)-(Select*fromemployment1). 
ANSWER 
QUESTION 46
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhichTCP/IPportdoesSQLServerrunon?Howcanitbechanged? 
48 
QUESTION 
SQLServerrunsonport1433.ItcanbechangedfromtheNetworkUtilityTCP/IPproperties. 
ANSWER 
QUESTION 47
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisSQLServerAgent? 
49 
QUESTION 
SQLServeragentplaysanimportantroleintheday-to-daytasksofadatabaseadministrator(DBA).ItspurposeistoeasetheimplementationoftasksfortheDBA,withitsfull-functionschedulingengine,whichallowsyoutoscheduleyourownjobsandscripts. 
ANSWER 
QUESTION 48
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhichcommandusingQueryAnalyzerwillgiveyoutheversionofSQLserverandoperatingsystem? 
50 
QUESTION 
SELECTSERVERPROPERTY('productversion'),SERVERPROPERTY('productlevel')andSERVERPROPERTY('edition') 
ANSWER 
QUESTION 49
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
HowtocreaterecursivequeryinSQLServer? 
51 
QUESTION 
RecursivequerycanbecreateinSQLusingstoredprocedurebutyoucanalsouseCTE(Commontableexpression).ItmightbealsoworthaskingaboutperformanceasCTEisnotalwaysveryfast. 
ANSWER 
QUESTION 51
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisaconstraint? 
52 
QUESTION 
Constraintcanbeusedtospecifythelimitonthedatatypeoftable.Constraintcanbespecifiedwhilecreatingoralteringthetablestatement.Sampleofconstraintare. 
•NOTNULL. 
•CHECK. 
•DEFAULT. 
•UNIQUE. 
•PRIMARYKEY. 
•FOREIGNKEY. 
ANSWER 
QUESTION 51
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisAutoIncrement? 
53 
QUESTION 
Autoincrementkeywordallowstheusertocreateauniquenumbertobegeneratedwhenanewrecordisinsertedintothetable.AUTOINCREMENTkeywordcanbeusedinOracleandIDENTITYkeywordcanbeusedinSQLSERVER. 
MostlythiskeywordcanbeusedwheneverPRIMARYKEYisused. 
ANSWER 
QUESTION 52
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisDatawarehouse? 
54 
QUESTION 
Datawarehouseisacentralrepositoryofdatafrommultiplesourcesofinformation.Thosedataareconsolidated, transformedandmadeavailablefortheminingandonlineprocessing.WarehousedatahaveasubsetofdatacalledDataMarts. 
ANSWER 
QUESTION 53
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisuserdefinedfunctions? 
55 
QUESTION 
Userdefinedfunctionsarethefunctionswrittentousethatlogicwheneverrequired.Itisnotnecessarytowritethesamelogicseveraltimes.Instead,functioncanbecalledorexecutedwheneverneeded. 
ANSWER 
QUESTION 54
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatarealltypesofuserdefinedfunctions? 
56 
QUESTION 
Threetypesofuserdefinedfunctionsare. 
a.ScalarFunctions. 
b.InlineTablevaluedfunctions. 
c.Multistatementvaluedfunctions. 
ANSWER 
QUESTION 55
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatarealldifferenttypesofcollationsensitivity? 
57 
QUESTION 
Followingaredifferenttypesofcollationsensitivity-. 
•CaseSensitivity–AandaandBandb. 
•AccentSensitivity. 
•KanaSensitivity–JapaneseKanacharacters. 
•WidthSensitivity–Singlebytecharacteranddoublebytecharacter. 
ANSWER 
QUESTION 56
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisOnlineTransactionProcessing(OLTP)? 
58 
QUESTION 
OnlineTransactionProcessingorOLTPmanagestransactionbasedapplicationswhichcanbeusedfordataentryandeasyretrievalprocessingofdata.Thisprocessingmakeslikeeasieronsimplicityandefficiency.Itisfaster, moreaccurateresultsandexpenseswithrespecttoOTLP. 
Example–BankTransactionsonadailybasis. 
ANSWER 
QUESTION 57
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisanALIAScommand? 
59 
QUESTION 
ALIASnamecanbegiventoatableorcolumn.ThisaliasnamecanbereferredinWHEREclausetoidentifythetableorcolumn. 
Example-. 
Selectst.StudentID,Ex.Resultfromstudentst,ExamasExwherest.studentID=Ex.StudentID 
Here,streferstoaliasnameforstudenttableandExreferstoaliasnameforexamtable. 
ANSWER 
QUESTION 58
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatareaggregateandscalarfunctions? 
60 
QUESTION 
Aggregatefunctionsareusedtoevaluatemathematicalcalculationandreturnsinglevalues.Thiscanbecalculatedfromthecolumnsinatable.Scalarfunctionsreturnasinglevaluebasedontheinputvalue. 
Example-. 
Aggregate–max(),count–Calculatedwithrespecttonumeric. 
Scalar–UCASE(),NOW()–Calculatedwithrespecttostrings. 
ANSWER 
QUESTION 59
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Howcanyoucreateanemptytablefromanexistingtable? 
61 
QUESTION 
Select*intostudentcopyfromstudentwhere1=2 
Here,wearecopyingstudenttabletoanothertablewiththesamestructurewithnorowscopied. 
ANSWER 
QUESTION 60
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Howtofetchcommonrecordsfromtwotables? 
62 
QUESTION 
Commonrecordsresultsetcanbeachievedby-. 
SelectstudentIDfromstudent.<strong>INTERSECT</strong>SelectStudentIDfromExam 
ANSWER 
QUESTION 61
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Howtoselectuniquerecordsfromatable? 
63 
QUESTION 
SelectuniquerecordsfromatablebyusingDISTINCTkeyword. 
SelectDISTINCTStudentID,StudentNamefromStudent. 
ANSWER 
QUESTION 62
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatarethedifferentindexconfigurationsatablecanhave? 
64 
QUESTION 
Atablecanhaveoneofthefollowingindexconfigurations: 
1.Noindexes 
2.Aclusteredindex 
3.Aclusteredindexandmanynonclusteredindexes 
4.Anonclusteredindex 
5.Manynonclusteredindexes 
ANSWER 
QUESTION 63
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatarethepropertiesanddifferentTypesofSub-Queries? 
65 
QUESTION 
PropertiesofSub-Query 
a.Asub-querymustbeenclosedintheparenthesis. 
b.Asub-querymustbeputintherighthandofthecomparisonoperator,and 
c.Asub-querycannotcontainanORDER-BYclause. 
d.Aquerycancontainmorethanonesub-query. 
TypesofSub-Query 
e.Single-rowsub-query,wherethesub-queryreturnsonlyonerow. 
f.Multiple-rowsub-query,wherethesub-queryreturnsmultiplerows,.and 
g.Multiplecolumnsub-query,wherethesub-queryreturnsmultiplecolumns 
ANSWER 
QUESTION 64
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisSQLProfiler? 
66 
QUESTION 
SQLProfilerisagraphicaltoolthatallowssystemadministratorstomonitoreventsinaninstanceofMicrosoftSQLServer.YoucancaptureandsavedataabouteacheventtoafileorSQLServertabletoanalyzelater.Forexample,youcanmonitoraproductionenvironmenttoseewhichstoredproceduresarehamperingperformancesbyexecutingtooslowly. 
UseSQLProfilertomonitoronlytheeventsinwhichyouareinterested.Iftracesarebecomingtoolarge,youcanfilterthembasedontheinformationyouwant,sothatonlyasubsetoftheeventdataiscollected.Monitoringtoomanyeventsaddsoverheadtotheserverandthemonitoringprocessandcancausethetracefileortracetabletogrowverylarge,especiallywhenthemonitoringprocesstakesplaceoveralongperiodoftime. 
ANSWER 
QUESTION 65
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhataretheauthenticationmodesinSQLServer?Howcanitbechanged? 
67 
QUESTION 
WindowsmodeandMixedMode-SQLandWindows.TochangeauthenticationmodeinSQLServerclickStart, Programs,MicrosoftSQLServerandclickSQLEnterpriseManagertorunSQLEnterpriseManagerfromtheMicrosoftSQLServerprogramgroup.SelecttheserverthenfromtheToolsmenuselectSQLServerConfigurationProperties,andchoosetheSecuritypage. 
ANSWER 
QUESTION 66
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Canastoredprocedurecallitselforrecursivestoredprocedure?HowmuchlevelSPnestingispossible? 
68 
QUESTION 
Yes.BecauseTransact-SQLsupportsrecursion,youcanwritestoredproceduresthatcallthemselves.Recursioncanbedefinedasamethodofproblemsolvingwhereinthesolutionisarrivedatbyrepetitivelyapplyingittosubsetsoftheproblem.Acommonapplicationofrecursivelogicistoperformnumericcomputationsthatlendthemselvestorepetitiveevaluationbythesameprocessingsteps.StoredproceduresarenestedwhenonestoredprocedurecallsanotherorexecutesmanagedcodebyreferencingaCLRroutine,type,oraggregate.Youcanneststoredproceduresandmanagedcodereferencesupto32levels. 
ANSWER 
QUESTION 67
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisLogShipping? 
69 
QUESTION 
LogshippingistheprocessofautomatingthebackupofdatabaseandtransactionlogfilesonaproductionSQLserver,andthenrestoringthemontoastandbyserver.EnterpriseEditionsonlysupportslogshipping.Inlogshippingthetransactionallogfilefromoneserverisautomaticallyupdatedintothebackupdatabaseontheotherserver.Ifoneserverfails,theotherserverwillhavethesamedbandcanbeusedthisastheDisasterRecoveryplan.Thekeyfeatureoflogshippingisthatitwillautomaticallybackuptransactionlogsthroughoutthedayandautomaticallyrestorethemonthestandbyserveratdefinedinterval. 
ANSWER 
QUESTION 68
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Name3waystogetanaccuratecountofthenumberofrecordsinatable? 
70 
QUESTION 
SELECT*FROMtable1 
SELECTCOUNT(*)FROMtable1 
SELECTrowsFROMsysindexesWHEREid=OBJECT_ID(table1)ANDindid<2 
ANSWER 
QUESTION 69
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatdoesitmeantohaveQUOTED_IDENTIFIERON?WhataretheimplicationsofhavingitOFF? 
71 
QUESTION 
WhenSETQUOTED_IDENTIFIERisON,identifierscanbedelimitedbydoublequotationmarks,andliteralsmustbedelimitedbysinglequotationmarks.WhenSETQUOTED_IDENTIFIERisOFF,identifierscannotbequotedandmustfollowallTransact-SQLrulesforidentifiers. 
ANSWER 
QUESTION 70
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisthedifferencebetweenaLocalandaGlobaltemporarytable? 
72 
QUESTION 
1.Alocaltemporarytableexistsonlyforthedurationofaconnectionor,ifdefinedinsideacompoundstatement,forthedurationofthecompoundstatement. 
2.Aglobaltemporarytableremainsinthedatabasepermanently,buttherowsexistonlywithinagivenconnection. Whenconnectionisclosed,thedataintheglobaltemporarytabledisappears.However,thetabledefinitionremainswiththedatabaseforaccesswhendatabaseisopenednexttime. 
ANSWER 
QUESTION 71
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
HowGlobaltemporarytablesarerepresentedanditsscope? 
73 
QUESTION 
Globaltemporarytablesarerepresentedwith##beforethetablename.Scopewillbetheoutsidethesessionwhereaslocaltemporarytablesareinsidethesession.SessionIDcanbefoundusing@@SPID. 
ANSWER 
QUESTION 72
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatistheSTUFFfunctionandhowdoesitdifferfromtheREPLACEfunction? 
74 
QUESTION 
STUFFfunctionisusedtooverwriteexistingcharacters.Usingthissyntax,STUFF(string_expression,start,length, replacement_characters),string_expressionisthestringthatwillhavecharacterssubstituted,startisthestartingposition,lengthisthenumberofcharactersinthestringthataresubstituted,andreplacement_charactersarethenewcharactersinterjectedintothestring.REPLACEfunctiontoreplaceexistingcharactersofalloccurrences. UsingthesyntaxREPLACE(string_expression,search_string,replacement_string),whereeveryincidenceofsearch_stringfoundinthestring_expressionwillbereplacedwithreplacement_string. 
ANSWER 
QUESTION 73
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisCHECKConstraint? 
75 
QUESTION 
ACHECKconstraintisusedtolimitthevaluesthatcanbeplacedinacolumn.Thecheckconstraintsareusedtoenforcedomainintegrity. 
ANSWER 
QUESTION 74
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisthedifferencebetweenUNIONandUNIONALL? 
76 
QUESTION 
UNIONstatementismainlyusedtocombinethetablesincludingtheduplicaterowsandUNIONALLcombinebutdoesnotlookforduplicaterows.Withthis,UNIONALLwillbeveryfasterthanUNIONstatements. 
ANSWER 
QUESTION 75
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisNOTNULLConstraint? 
77 
QUESTION 
ANOTNULLconstraintenforcesthatthecolumnwillnotacceptnullvalues.Thenotnullconstraintsareusedtoenforcedomainintegrity,asthecheckconstraints. 
ANSWER 
QUESTION 76
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Howtoget@@ERRORand@@ROWCOUNTatthesametime? 
78 
QUESTION 
If@@RowcountischeckedafterErrorcheckingstatementthenitwillhave0asthevalueof@@Recordcountasitwouldhavebeenreset.Andif@@Recordcountischeckedbeforetheerror-checkingstatementthen@@Errorwouldgetreset.Toget@@errorand@@rowcountatthesametimedobothinsamestatementandstoretheminlocalvariable. 
SELECT@RC=@@ROWCOUNT,@ER=@@ERROR 
ANSWER 
QUESTION 77
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisaScheduledJobsorWhatisaScheduledTasks? 
79 
QUESTION 
Scheduledtasksletuserautomateprocessesthatrunonregularorpredictablecycles.Usercanscheduleadministrativetasks,suchascubeprocessing,torunduringtimesofslowbusinessactivity.UsercanalsodeterminetheorderinwhichtasksrunbycreatingjobstepswithinaSQLServerAgentjob.E.g.backupdatabase,UpdateStatsofTables.Jobstepsgiveusercontroloverflowofexecution.Ifonejobfails,usercanconfigureSQLServerAgenttocontinuetoruntheremainingtasksortostopexecution. 
ANSWER 
QUESTION 78
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisatablecalled,ifithasneitherClusternorNon-clusterIndex?Whatisitusedfor? 
80 
QUESTION 
UnindexedtableorHeap.MicrosoftPressBooksandBookonLine(BOL)refersitasHeap.Aheapisatablethatdoesnothaveaclusteredindexand,therefore,thepagesarenotlinkedbypointers.TheIAMpagesaretheonlystructuresthatlinkthepagesinatabletogether.Unindexedtablesaregoodforfaststoringofdata.Manytimesitisbettertodropallindexesfromtableandthendobulkofinsertsandtorestorethoseindexesafterthat. 
ANSWER 
QUESTION 79
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
CanSQLServerslinkedtootherserverslikeOracle? 
81 
QUESTION 
SQLServercanbelinkedtoanyserverprovidedithasOLE-DBproviderfromMicrosofttoallowalink.E.g.OraclehasanOLE-DBproviderfororaclethatMicrosoftprovidestoadditaslinkedservertoSQLServergroup. 
ANSWER 
QUESTION 80
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisBCP?Whendoesitused? 
82 
QUESTION 
BulkCopyisatoolusedtocopyhugeamountofdatafromtablesandviews.BCPdoesnotcopythestructuressameassourcetodestination.BULKINSERTcommandhelpstoimportadatafileintoadatabasetableorviewinauser-specifiedformat. 
ANSWER 
QUESTION 81
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Howtoimplementone-to-one,one-to-manyandmany-to-manyrelationshipswhiledesigningtables? 
83 
QUESTION 
One-to-Onerelationshipcanbeimplementedasasingletableandrarelyastwotableswithprimaryandforeignkeyrelationships.One-to-Manyrelationshipsareimplementedbysplittingthedataintotwotableswithprimarykeyandforeignkeyrelationships.Many-to-Manyrelationshipsareimplementedusingajunctiontablewiththekeysfromboththetablesformingthecompositeprimarykeyofthejunctiontable. 
ANSWER 
QUESTION 82
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisanexecutionplan?Whenwouldyouuseit?Howwouldyouviewtheexecutionplan? 
84 
QUESTION 
AnexecutionplanisbasicallyaroadmapthatgraphicallyortextuallyshowsthedataretrievalmethodschosenbytheSQLServerqueryoptimizerforastoredprocedureorad-hocqueryandisaveryusefultoolforadevelopertounderstandtheperformancecharacteristicsofaqueryorstoredproceduresincetheplanistheonethatSQLServerwillplaceinitscacheandusetoexecutethestoredprocedureorquery.FromwithinQueryAnalyzerisanoptioncalled"ShowExecutionPlan"(locatedontheQuerydrop-downmenu).Ifthisoptionisturnedonitwilldisplayqueryexecutionplaninseparatewindowwhenqueryisranagain. 
ANSWER 
QUESTION 83
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatarethetwoauthenticationmodesinSQLServer? 
85 
QUESTION 
Therearetwoauthenticationmodes– 
•WindowsMode 
•MixedMode 
ModescanbechangedbyselectingthetoolsmenuofSQLServerconfigurationpropertiesandchoosesecuritypage. 
ANSWER 
QUESTION 84
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisCOALESCEinSQLServer? 
86 
QUESTION 
COALESCEisusedtoreturnfirstnon-nullexpressionwithinthearguments.Thisfunctionisusedtoreturnanon- nullfrommorethanonecolumninthearguments. 
Example– 
SelectCOALESCE(empno,empname,salary)fromemployee; 
ANSWER 
QUESTION 85
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
HowexceptionscanbehandledinSQLServerProgramming? 
87 
QUESTION 
ExceptionsarehandledusingTRY—-CATCHconstructsanditishandlesbywritingscriptsinsidetheTRYblockanderrorhandlingintheCATCHblock. 
ANSWER 
QUESTION 86
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisthepurposeofFLOORfunction? 
88 
QUESTION 
FLOORfunctionisusedtoroundupanon-integervaluetothepreviousleastinteger.ExampleisgivenFLOOR(6.7) 
Returns6. 
ANSWER 
QUESTION 87
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Canwechecklocksindatabase?Ifso,howcanwedothislockcheck? 
89 
QUESTION 
Yes,wecanchecklocksinthedatabase.Itcanbeachievedbyusingin-builtstoredprocedurecalledsp_lock. 
ANSWER 
QUESTION 88
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatistheuseofSIGNfunction? 
90 
QUESTION 
SIGNfunctionisusedtodeterminewhetherthenumberspecifiedisPositive,NegativeandZero.Thiswillreturn+1,-1or0. 
Example:SIGN(-35)returns-1 
ANSWER 
QUESTION 89
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
HowistheSUBSTRkeywordusedinSQL? 
91 
QUESTION 
SUBSTRisusedforstringmanipulationwithcolumnname,firstpositionandstringlengthusedasarguments.E.g. 
SUBSTR(NAME,13)referstothefirstthreecharactersinthecolumnNAME. 
ANSWER 
QUESTION 90
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisaNULLvalue?WhataretheprosandconsofusingNULLS? 
92 
QUESTION 
ANULLvaluetakesuponebyteofstorageandindicatesthatavalueisnotpresentasopposedtoaspaceorzerovalue.It'stheDB2equivalentofTBDonanorganizationalchartandoftencorrectlyportraysabusinesssituation. Unfortunately,itrequiresextracodingforanapplicationprogramtohandlethissituation. 
ANSWER 
QUESTION 91
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisasynonym?Howisitused? 
93 
QUESTION 
Asynonymisusedtoreferenceatableorviewbyanothername.Theothernamecanthenbewrittenintheapplicationcodepointingtotesttablesinthedevelopmentstageandtoproductionentitieswhenthecodeismigrated.ThesynonymislinkedtotheAUTHIDthatcreatedit. 
ANSWER 
QUESTION 92
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisaCartesianproduct? 
94 
QUESTION 
ACartesianproductresultsfromafaultyquery.Itisarowintheresultsforeverycombinationinthejointables. 
ANSWER 
QUESTION 93
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisatuple? 
95 
QUESTION 
StaticSQLiscompiledandoptimizedpriortoitsexecution;dynamiciscompiledandoptimizedduringexecution. 
ANSWER 
QUESTION 94
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Whatisreferentialintegrity? 
96 
QUESTION 
Referentialintegrityreferstotheconsistencythatmustbemaintainedbetweenprimaryandforeignkeys,i.e.everyforeignkeyvaluemusthaveacorrespondingprimarykeyvalue. 
ANSWER 
QUESTION 95
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
What’sthemaximumsizeofarow? 
97 
QUESTION 
8060bytes. 
ANSWER 
QUESTION 96
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
HowtochangeDatabasenameinSQLserver? 
98 
QUESTION 
Usethefollowingcode: 
SupportedinSQLserver2000and2005 
Execsp_renamedb―test‖,―test1‖ 
SupportedinSQLServer2005andlaterversion 
ALTERDatabase―test1‖ModifyName=―test‖ 
ANSWER 
QUESTION 97
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisaCursor? 
99 
QUESTION 
AdatabaseCursorisacontrolwhichenablestraversalovertherowsorrecordsinthetable.Thiscanbeviewedasapointertoonerowinasetofrows.Cursorisverymuchusefulfortraversingsuchasretrieval,additionandremovalofdatabaserecords. 
ANSWER 
QUESTION 98
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatareMagicTablesinSQLServer? 
100 
QUESTION 
InsertandDeletetablesarecreatedwhenthetriggerisfiredforanyDMLcommand.ThosetablesarecalledMagicTablesinSQLServer.Thesemagictablesareusedinsidethetriggersfordatatransaction. 
ANSWER 
QUESTION 99
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
WhatisISNULL()operator? 
101 
QUESTION 
ISNULLfunctionisusedtocheckwhethervaluegivenisNULLornotNULLinsqlserver.ThisfunctionalsoprovidestoreplaceavaluewiththeNULL. 
ANSWER 
QUESTION 100
For the hottest SQL jobs, please visit www.hirist.com 
hirist 
.com 
Resources 
102 
http://www.itechaleart.com/2013/05/top-50-sql-question-answers_11.html 
https://www.katieandemil.com/sql-interview-questions-and- answers?tab=article#Question 4 
http://www.dwbiconcepts.com/tutorial/24-interview-questions/190-top-20-sql- interview-questions-with-answers.html 
http://a4academics.com/interview-questions/53-database-and-sql/411-sql- interview-questions-and-answers-database 
http://narendra86.blogspot.com/2013/10/top-80-sql-query-interview- questions.html 
http://crackaninterview.com/sql-queries-interview-questions-answers/ 
http://career.guru99.com/top-50-sql-question-answers/ 
http://www.indiabix.com/technical/sql-server-common-questions/ 
http://career.guru99.com/top-50-sql-server-questions-answers/ 
http://www.ittestpapers.com/sql-interview-questions(25-50).html 
http://www.dotnetfunda.com/interviews/cat/8/sql-server 
http://www.careerride.com/SQLServer-Interview-Questions.aspx
www.hirist.com 
SQL 
TOP 100 
INTERVIEW QUESTIONS & ANSWERS

More Related Content

What's hot (20)

SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
SQL
SQLSQL
SQL
 
SQL Functions
SQL FunctionsSQL Functions
SQL Functions
 
Sql and Sql commands
Sql and Sql commandsSql and Sql commands
Sql and Sql commands
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
 
Triggers in SQL | Edureka
Triggers in SQL | EdurekaTriggers in SQL | Edureka
Triggers in SQL | Edureka
 
Sql commands
Sql commandsSql commands
Sql commands
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
 
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
SQL practice questions set - 2
SQL practice questions set - 2SQL practice questions set - 2
SQL practice questions set - 2
 
Tableau LOD Expressions | Edureka
Tableau LOD Expressions | EdurekaTableau LOD Expressions | Edureka
Tableau LOD Expressions | Edureka
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
SQL JOIN
SQL JOINSQL JOIN
SQL JOIN
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
Sql queires
Sql queiresSql queires
Sql queires
 
Sql
SqlSql
Sql
 

Similar to Top 100 SQL Interview Questions and Answers

Top 100 .NET Interview Questions and Answers
Top 100 .NET Interview Questions and AnswersTop 100 .NET Interview Questions and Answers
Top 100 .NET Interview Questions and AnswersTung Nguyen Thanh
 
Diagnose RIDPool Failures
Diagnose RIDPool FailuresDiagnose RIDPool Failures
Diagnose RIDPool FailuresCuneyt Goksu
 
Top jcl interview questions and answers job interview tips
Top jcl interview questions and answers job interview tipsTop jcl interview questions and answers job interview tips
Top jcl interview questions and answers job interview tipsjcltutorial
 
What Your Database Query is Really Doing
What Your Database Query is Really DoingWhat Your Database Query is Really Doing
What Your Database Query is Really DoingDave Stokes
 
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | EdurekaSQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | EdurekaEdureka!
 
Salesforce developer fa qs
Salesforce developer fa qsSalesforce developer fa qs
Salesforce developer fa qsRakesh Joshi
 
Salesforce developer fa qs
Salesforce developer fa qsSalesforce developer fa qs
Salesforce developer fa qsRakesh Joshi
 
Fai[ Away with Dynamo, Bigtabte, and Cassandra194 cHArlrEF.docx
Fai[ Away with Dynamo, Bigtabte, and Cassandra194 cHArlrEF.docxFai[ Away with Dynamo, Bigtabte, and Cassandra194 cHArlrEF.docx
Fai[ Away with Dynamo, Bigtabte, and Cassandra194 cHArlrEF.docxssuser454af01
 
Semantic Web Standards and the Variety “V” of Big Data
Semantic Web Standards and  the Variety “V” of Big DataSemantic Web Standards and  the Variety “V” of Big Data
Semantic Web Standards and the Variety “V” of Big Databobdc
 
Sybase job interview_preparation_guide
Sybase job interview_preparation_guideSybase job interview_preparation_guide
Sybase job interview_preparation_guideNV Suresh Kumar
 
Optimizing Your Database Performance | Embarcadero Technologies
Optimizing Your Database Performance | Embarcadero TechnologiesOptimizing Your Database Performance | Embarcadero Technologies
Optimizing Your Database Performance | Embarcadero TechnologiesEmbarcadero Technologies
 
Optimizing Your Database Performance | Embarcadero Technologies
Optimizing Your Database Performance | Embarcadero TechnologiesOptimizing Your Database Performance | Embarcadero Technologies
Optimizing Your Database Performance | Embarcadero TechnologiesMichael Findling
 
Financial, Retail And Shopping Domains
Financial, Retail And Shopping DomainsFinancial, Retail And Shopping Domains
Financial, Retail And Shopping DomainsSonia Sanchez
 
Smu mba sem 3 mis winter 2014 assignments
Smu mba sem 3 mis winter 2014 assignmentsSmu mba sem 3 mis winter 2014 assignments
Smu mba sem 3 mis winter 2014 assignmentssolved_assignments
 
Erp cloud white paper final
Erp cloud white paper finalErp cloud white paper final
Erp cloud white paper finalraisinli
 
SQL For Programmers -- Boston Big Data Techcon April 27th
SQL For Programmers -- Boston Big Data Techcon April 27thSQL For Programmers -- Boston Big Data Techcon April 27th
SQL For Programmers -- Boston Big Data Techcon April 27thDave Stokes
 

Similar to Top 100 SQL Interview Questions and Answers (20)

Top 100 .NET Interview Questions and Answers
Top 100 .NET Interview Questions and AnswersTop 100 .NET Interview Questions and Answers
Top 100 .NET Interview Questions and Answers
 
Diagnose RIDPool Failures
Diagnose RIDPool FailuresDiagnose RIDPool Failures
Diagnose RIDPool Failures
 
Dit yvol3iss4
Dit yvol3iss4Dit yvol3iss4
Dit yvol3iss4
 
Top jcl interview questions and answers job interview tips
Top jcl interview questions and answers job interview tipsTop jcl interview questions and answers job interview tips
Top jcl interview questions and answers job interview tips
 
Integration in The Cloud
Integration in The CloudIntegration in The Cloud
Integration in The Cloud
 
What Your Database Query is Really Doing
What Your Database Query is Really DoingWhat Your Database Query is Really Doing
What Your Database Query is Really Doing
 
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | EdurekaSQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
 
Salesforce developer fa qs
Salesforce developer fa qsSalesforce developer fa qs
Salesforce developer fa qs
 
Salesforce developer fa qs
Salesforce developer fa qsSalesforce developer fa qs
Salesforce developer fa qs
 
Fai[ Away with Dynamo, Bigtabte, and Cassandra194 cHArlrEF.docx
Fai[ Away with Dynamo, Bigtabte, and Cassandra194 cHArlrEF.docxFai[ Away with Dynamo, Bigtabte, and Cassandra194 cHArlrEF.docx
Fai[ Away with Dynamo, Bigtabte, and Cassandra194 cHArlrEF.docx
 
Semantic Web Standards and the Variety “V” of Big Data
Semantic Web Standards and  the Variety “V” of Big DataSemantic Web Standards and  the Variety “V” of Big Data
Semantic Web Standards and the Variety “V” of Big Data
 
Sybase job interview_preparation_guide
Sybase job interview_preparation_guideSybase job interview_preparation_guide
Sybase job interview_preparation_guide
 
Optimizing Your Database Performance | Embarcadero Technologies
Optimizing Your Database Performance | Embarcadero TechnologiesOptimizing Your Database Performance | Embarcadero Technologies
Optimizing Your Database Performance | Embarcadero Technologies
 
Optimizing Your Database Performance | Embarcadero Technologies
Optimizing Your Database Performance | Embarcadero TechnologiesOptimizing Your Database Performance | Embarcadero Technologies
Optimizing Your Database Performance | Embarcadero Technologies
 
Financial, Retail And Shopping Domains
Financial, Retail And Shopping DomainsFinancial, Retail And Shopping Domains
Financial, Retail And Shopping Domains
 
10 sql tips
10 sql tips10 sql tips
10 sql tips
 
Web 2.0 Development with IBM DB2
Web 2.0 Development with IBM DB2Web 2.0 Development with IBM DB2
Web 2.0 Development with IBM DB2
 
Smu mba sem 3 mis winter 2014 assignments
Smu mba sem 3 mis winter 2014 assignmentsSmu mba sem 3 mis winter 2014 assignments
Smu mba sem 3 mis winter 2014 assignments
 
Erp cloud white paper final
Erp cloud white paper finalErp cloud white paper final
Erp cloud white paper final
 
SQL For Programmers -- Boston Big Data Techcon April 27th
SQL For Programmers -- Boston Big Data Techcon April 27thSQL For Programmers -- Boston Big Data Techcon April 27th
SQL For Programmers -- Boston Big Data Techcon April 27th
 

Recently uploaded

Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Servicejennyeacort
 
办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一
办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一
办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一A SSS
 
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...Suhani Kapoor
 
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一Fs
 
办澳洲詹姆斯库克大学毕业证成绩单pdf电子版制作修改
办澳洲詹姆斯库克大学毕业证成绩单pdf电子版制作修改办澳洲詹姆斯库克大学毕业证成绩单pdf电子版制作修改
办澳洲詹姆斯库克大学毕业证成绩单pdf电子版制作修改yuu sss
 
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
NPPE STUDY GUIDE - NOV2021_study_104040.pdf
NPPE STUDY GUIDE - NOV2021_study_104040.pdfNPPE STUDY GUIDE - NOV2021_study_104040.pdf
NPPE STUDY GUIDE - NOV2021_study_104040.pdfDivyeshPatel234692
 
MIdterm Review International Trade.pptx review
MIdterm Review International Trade.pptx reviewMIdterm Review International Trade.pptx review
MIdterm Review International Trade.pptx reviewSheldon Byron
 
Escort Service Andheri WhatsApp:+91-9833363713
Escort Service Andheri WhatsApp:+91-9833363713Escort Service Andheri WhatsApp:+91-9833363713
Escort Service Andheri WhatsApp:+91-9833363713Riya Pathan
 
Gray Gold Clean CV Resume2024tod (1).pdf
Gray Gold Clean CV Resume2024tod (1).pdfGray Gold Clean CV Resume2024tod (1).pdf
Gray Gold Clean CV Resume2024tod (1).pdfpadillaangelina0023
 
tools in IDTelated to first year vtu students is useful where they can refer ...
tools in IDTelated to first year vtu students is useful where they can refer ...tools in IDTelated to first year vtu students is useful where they can refer ...
tools in IDTelated to first year vtu students is useful where they can refer ...vinbld123
 
Kindergarten-DLL-MELC-Q3-Week 2 asf.docx
Kindergarten-DLL-MELC-Q3-Week 2 asf.docxKindergarten-DLL-MELC-Q3-Week 2 asf.docx
Kindergarten-DLL-MELC-Q3-Week 2 asf.docxLesterJayAquino
 
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一Fs sss
 
办理(NUS毕业证书)新加坡国立大学毕业证成绩单原版一比一
办理(NUS毕业证书)新加坡国立大学毕业证成绩单原版一比一办理(NUS毕业证书)新加坡国立大学毕业证成绩单原版一比一
办理(NUS毕业证书)新加坡国立大学毕业证成绩单原版一比一F La
 
Call Girl in Low Price Delhi Punjabi Bagh 9711199012
Call Girl in Low Price Delhi Punjabi Bagh  9711199012Call Girl in Low Price Delhi Punjabi Bagh  9711199012
Call Girl in Low Price Delhi Punjabi Bagh 9711199012sapnasaifi408
 
原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量
原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量
原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量sehgh15heh
 
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一2s3dgmej
 
Digital Marketing Training Institute in Mohali, India
Digital Marketing Training Institute in Mohali, IndiaDigital Marketing Training Institute in Mohali, India
Digital Marketing Training Institute in Mohali, IndiaDigital Discovery Institute
 
Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607
Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607
Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607dollysharma2066
 
Ethics of Animal Research Laika mission.ppt
Ethics of Animal Research Laika mission.pptEthics of Animal Research Laika mission.ppt
Ethics of Animal Research Laika mission.pptShafqatShakeel1
 

Recently uploaded (20)

Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
 
办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一
办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一
办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一
 
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
 
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
 
办澳洲詹姆斯库克大学毕业证成绩单pdf电子版制作修改
办澳洲詹姆斯库克大学毕业证成绩单pdf电子版制作修改办澳洲詹姆斯库克大学毕业证成绩单pdf电子版制作修改
办澳洲詹姆斯库克大学毕业证成绩单pdf电子版制作修改
 
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
格里菲斯大学毕业证(Griffith毕业证)#文凭成绩单#真实留信学历认证永久存档
 
NPPE STUDY GUIDE - NOV2021_study_104040.pdf
NPPE STUDY GUIDE - NOV2021_study_104040.pdfNPPE STUDY GUIDE - NOV2021_study_104040.pdf
NPPE STUDY GUIDE - NOV2021_study_104040.pdf
 
MIdterm Review International Trade.pptx review
MIdterm Review International Trade.pptx reviewMIdterm Review International Trade.pptx review
MIdterm Review International Trade.pptx review
 
Escort Service Andheri WhatsApp:+91-9833363713
Escort Service Andheri WhatsApp:+91-9833363713Escort Service Andheri WhatsApp:+91-9833363713
Escort Service Andheri WhatsApp:+91-9833363713
 
Gray Gold Clean CV Resume2024tod (1).pdf
Gray Gold Clean CV Resume2024tod (1).pdfGray Gold Clean CV Resume2024tod (1).pdf
Gray Gold Clean CV Resume2024tod (1).pdf
 
tools in IDTelated to first year vtu students is useful where they can refer ...
tools in IDTelated to first year vtu students is useful where they can refer ...tools in IDTelated to first year vtu students is useful where they can refer ...
tools in IDTelated to first year vtu students is useful where they can refer ...
 
Kindergarten-DLL-MELC-Q3-Week 2 asf.docx
Kindergarten-DLL-MELC-Q3-Week 2 asf.docxKindergarten-DLL-MELC-Q3-Week 2 asf.docx
Kindergarten-DLL-MELC-Q3-Week 2 asf.docx
 
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
 
办理(NUS毕业证书)新加坡国立大学毕业证成绩单原版一比一
办理(NUS毕业证书)新加坡国立大学毕业证成绩单原版一比一办理(NUS毕业证书)新加坡国立大学毕业证成绩单原版一比一
办理(NUS毕业证书)新加坡国立大学毕业证成绩单原版一比一
 
Call Girl in Low Price Delhi Punjabi Bagh 9711199012
Call Girl in Low Price Delhi Punjabi Bagh  9711199012Call Girl in Low Price Delhi Punjabi Bagh  9711199012
Call Girl in Low Price Delhi Punjabi Bagh 9711199012
 
原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量
原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量
原版定制copy澳洲查尔斯达尔文大学毕业证CDU毕业证成绩单留信学历认证保障质量
 
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
定制(NYIT毕业证书)美国纽约理工学院毕业证成绩单原版一比一
 
Digital Marketing Training Institute in Mohali, India
Digital Marketing Training Institute in Mohali, IndiaDigital Marketing Training Institute in Mohali, India
Digital Marketing Training Institute in Mohali, India
 
Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607
Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607
Gurgaon Call Girls: Free Delivery 24x7 at Your Doorstep G.G.N = 8377087607
 
Ethics of Animal Research Laika mission.ppt
Ethics of Animal Research Laika mission.pptEthics of Animal Research Laika mission.ppt
Ethics of Animal Research Laika mission.ppt
 

Top 100 SQL Interview Questions and Answers

  • 1. hirist .com www.hirist.com SQL TOP 100 INTERVIEW QUESTIONS & ANSWERS
  • 2. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisDBMS? 2 QUESTION ADatabaseManagementSystem(DBMS)isaprogramthatcontrolscreation,maintenanceanduseofadatabase. DBMScanbetermedasFileManagerthatmanagesdatainadatabaseratherthansavingitinfilesystems. ANSWER QUESTION 1
  • 3. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisRDBMS? 3 QUESTION RDBMSstandsforRelationalDatabaseManagementSystem.RDBMSstorethedataintothecollectionoftables, whichisrelatedbycommonfieldsbetweenthecolumnsofthetable.Italsoprovidesrelationaloperatorstomanipulatethedatastoredintothetables. Example:SQLServer. ANSWER QUESTION 2
  • 4. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisSQL? 4 QUESTION SQLstandsforStructuredQueryLanguage,anditisusedtocommunicatewiththeDatabase.Thisisastandardlanguageusedtoperformtaskssuchasretrieval,updation,insertionanddeletionofdatafromadatabase. StandardSQLCommandsareSelect. ANSWER QUESTION 3
  • 5. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisaDatabase? 5 QUESTION Databaseisnothingbutanorganizedformofdataforeasyaccess,storing,retrievalandmanagingofdata.Thisisalsoknownasstructuredformofdatawhichcanbeaccessedinmanyways. Example:SchoolManagementDatabase,BankManagementDatabase. ANSWER QUESTION 4
  • 6. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhataretablesandFields? 6 QUESTION AtableisasetofdatathatareorganizedinamodelwithColumnsandRows.Columnscanbecategorizedasvertical,andRowsarehorizontal.Atablehasspecifiednumberofcolumncalledfieldsbutcanhaveanynumberofrowswhichiscalledrecord. Example:. Table:Employee. Field:EmpID,EmpName,DateofBirth. Data:201456,David,11/15/1960. ANSWER QUESTION 5
  • 7. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisaprimarykey? 7 QUESTION Aprimarykeyisacombinationoffieldswhichuniquelyspecifyarow.Thisisaspecialkindofuniquekey,andithasimplicitNOTNULLconstraint.Itmeans,PrimarykeyvaluescannotbeNULL. ANSWER QUESTION 6
  • 8. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisauniquekey? 8 QUESTION AUniquekeyconstraintuniquelyidentifiedeachrecordinthedatabase.Thisprovidesuniquenessforthecolumnorsetofcolumns. APrimarykeyconstrainthasautomaticuniqueconstraintdefinedonit.Butnot,inthecaseofUniqueKey. Therecanbemanyuniqueconstraintdefinedpertable,butonlyonePrimarykeyconstraintdefinedpertable. ANSWER QUESTION 7
  • 9. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisaforeignkey? 9 QUESTION Aforeignkeyisonetablewhichcanberelatedtotheprimarykeyofanothertable.Relationshipneedstobecreatedbetweentwotablesbyreferencingforeignkeywiththeprimarykeyofanothertable. ANSWER QUESTION 8
  • 10. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatarethetypesofjoinandexplaineach? 10 QUESTION Therearevarioustypesofjoinwhichcanbeusedtoretrievedataanditdependsontherelationshipbetweentables. InnerJoin:Innerjoinreturnrowswhenthereisatleastonematchofrowsbetweenthetables. RightJoin:RightjoinreturnrowswhicharecommonbetweenthetablesandallrowsofRighthandsidetable. Simply,itreturnsalltherowsfromtherighthandsidetableeventhoughtherearenomatchesinthelefthandsidetable. LeftJoin:LeftjoinreturnrowswhicharecommonbetweenthetablesandallrowsofLefthandsidetable.Simply,itreturnsalltherowsfromLefthandsidetableeventhoughtherearenomatchesintheRighthandsidetable. FullJoin:Fulljoinreturnrowswhentherearematchingrowsinanyoneofthetables.Thismeans,itreturnsalltherowsfromthelefthandsidetableandalltherowsfromtherighthandsidetable. ANSWER QUESTION 9
  • 11. For the hottest SQL jobs, please visit www.hirist.com hirist .com Explainanouterjoin? 11 QUESTION Anouterjoinincludesrowsfromtableswhentherearenomatchingvaluesinthetables. ANSWER QUESTION 10
  • 12. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisnormalization? 12 QUESTION Normalizationistheprocessofminimizingredundancyanddependencybyorganizingfieldsandtableofadatabase.ThemainaimofNormalizationistoadd,deleteormodifyfieldthatcanbemadeinasingletable. ANSWER QUESTION 11
  • 13. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisDenormalization? 13 QUESTION DeNormalizationisatechniqueusedtoaccessthedatafromhighertolowernormalformsofdatabase.Itisalsoprocessofintroducingredundancyintoatablebyincorporatingdatafromtherelatedtables. ANSWER QUESTION 12
  • 14. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatareallthedifferentnormalizations? 14 QUESTION Thenormalformscanbedividedinto4forms,andtheyareexplainedbelow-. FirstNormalForm(1NF):Thisshouldremovealltheduplicatecolumnsfromthetable.Creationoftablesfortherelateddataandidentificationofuniquecolumns. SecondNormalForm(2NF):Meetingallrequirementsofthefirstnormalform.PlacingthesubsetsofdatainseparatetablesandCreationofrelationshipsbetweenthetablesusingprimarykeys. ThirdNormalForm(3NF):Thisshouldmeetallrequirementsof2NF.Removingthecolumnswhicharenotdependentonprimarykeyconstraints. FourthNormalForm(4NF):Meetingalltherequirementsofthirdnormalformanditshouldnothavemulti- valueddependencies. ANSWER QUESTION 13
  • 15. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisanIndex?Whatareallthedifferenttypesofindexes? 15 QUESTION Anindexisperformancetuningmethodofallowingfasterretrievalofrecordsfromthetable.Anindexcreatesanentryforeachvalueanditwillbefastertoretrievedata. Thisindexingdoesnotallowthefieldtohaveduplicatevaluesifthecolumnisuniqueindexed.Uniqueindexcanbeappliedautomaticallywhenprimarykeyisdefined. ClusteredIndex:Thistypeofindexreordersthephysicalorderofthetableandsearchbasedonthekeyvalues. Eachtablecanhaveonlyoneclusteredindex. NonClusteredIndex:NonClusteredIndexdoesnotalterthephysicalorderofthetableandmaintainslogicalorderofdata.Eachtablecanhave999nonclusteredindexes. ANSWER QUESTION 14
  • 16. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisarelationshipandwhatarethey? 16 QUESTION DatabaseRelationshipisdefinedastheconnectionbetweenthetablesinadatabase.Therearevariousdatabasingrelationships,andtheyareasfollows:. OnetoOneRelationship. OnetoManyRelationship. ManytoOneRelationship. Self-ReferencingRelationship. ANSWER QUESTION 15
  • 17. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisaquery? 17 QUESTION ADBqueryisacodewritteninordertogettheinformationbackfromthedatabase.Querycanbedesignedinsuchawaythatitmatchedwithourexpectationoftheresultset.Simply,aquestiontotheDatabase. ANSWER QUESTION 16
  • 18. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatissubquery?Whatarethetypesofsubquery? 18 QUESTION Asubqueryisaquerywithinanotherquery.Theouterqueryiscalledasmainquery,andinnerqueryiscalledsubquery.SubQueryisalwaysexecutedfirst,andtheresultofsubqueryispassedontothemainquery. Therearetwotypesofsubquery–CorrelatedandNon-Correlated. Acorrelatedsubquerycannotbeconsideredasindependentquery,butitcanreferthecolumninatablelistedintheFROMthelistofthemainquery. ANon-Correlatedsubquerycanbeconsideredasindependentqueryandtheoutputofsubqueryaresubstitutedinthemainquery. ANSWER QUESTION 17
  • 19. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisatrigger? 19 QUESTION ADBtriggerisacodeorprogramsthatautomaticallyexecutewithresponsetosomeeventonatableorviewinadatabase.Mainly,triggerhelpstomaintaintheintegrityofthedatabase. Example:Whenanewstudentisaddedtothestudentdatabase,newrecordsshouldbecreatedintherelatedtableslikeExam,ScoreandAttendancetables. ANSWER QUESTION 18
  • 20. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatarethetypesofTriggers? 20 QUESTION Therearefourtypesoftriggersandtheyare: •Insert •Delete •Update •Insteadof ANSWER QUESTION 19
  • 21. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisthedifferencebetweenDELETETRUNCATEandDROPcommands? 21 QUESTION DELETEcommandisusedtoremoverowsfromthetable,andWHEREclausecanbeusedforconditionalsetofparameters.CommitandRollbackcanbeperformedafterdeletestatement. TRUNCATEremovesallrowsfromthetable.Truncateoperationcannotberolledback. Dropcommandisusedtodropthetableorkeyslikeprimary,foreignfromatable. ANSWER QUESTION 20
  • 22. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisdataIntegrity? 22 QUESTION DataIntegritydefinestheaccuracyandconsistencyofdatastoredinadatabase.Itcanalsodefineintegrityconstraintstoenforcebusinessrulesonthedatawhenitisenteredintotheapplicationordatabase. ANSWER QUESTION 21
  • 23. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatiscollation? 23 QUESTION Collationisdefinedassetofrulesthatdeterminehowcharacterdatacanbesortedandcompared.ThiscanbeusedtocompareAand,otherlanguagecharactersandalsodependsonthewidthofthecharacters. ASCIIvaluecanbeusedtocomparethesecharacterdata. ANSWER QUESTION 22
  • 24. For the hottest SQL jobs, please visit www.hirist.com hirist .com AdvantagesandDisadvantagesofStoredProcedure? 24 QUESTION Storedprocedurecanbeusedasamodularprogramming–meanscreateonce,storeandcallforseveraltimeswheneverrequired.Thissupportsfasterexecutioninsteadofexecutingmultiplequeries.Thisreducesnetworktrafficandprovidesbettersecuritytothedata. DisadvantageisthatitcanbeexecutedonlyintheDatabaseandutilizesmorememoryinthedatabaseserver. ANSWER QUESTION 23
  • 25. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisSQLInjection? 25 QUESTION SQLInjectionisoneofthetechniquesusesbyhackerstohackawebsitebyinjectingSQLcommandsindatafields. ANSWER QUESTION 24
  • 26. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisthedifferencebetweenaHAVINGCLAUSEandaWHERECLAUSE? 26 QUESTION Theyspecifyasearchconditionforagrouporanaggregate.ButthedifferenceisthatHAVINGcanbeusedonlywiththeSELECTstatement.HAVINGistypicallyusedinaGROUPBYclause.WhenGROUPBYisnotused, HAVINGbehaveslikeaWHEREclause.HavingClauseisbasicallyusedonlywiththeGROUPBYfunctioninaquerywhereasWHEREClauseisappliedtoeachrowbeforetheyarepartoftheGROUPBYfunctioninaquery. ANSWER QUESTION 25
  • 27. For the hottest SQL jobs, please visit www.hirist.com hirist .com Howwouldapplydaterangefilter? 27 QUESTION a.Youcanusesimplecondition>=and<=orsimilarorusebetween/andbutthetrickistoknowyourexactdatatype. b.Sometimesdatefieldscontaintimeandthatiswherethequerycangowrongsoitisrecommendedtousesomedaterelatedfunctionstoremovethetimeissue.InSQLServercommonfunctiontodothatisdatedifffunction. c.Youalsohavetobeawareofdifferenttimezonesandservertimezone. d.Toincreasequeryperformanceyoumaystillwanttousebetweenhoweveryoushouldbeawareofproperformatyoushoulduseifnotitmightmisbehaveduringfiltering. ANSWER QUESTION 26
  • 28. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisthedifferencebetweenJOINandUNION? 28 QUESTION SQLJOINallowsusto―lookup‖recordsonothertablebasedonthegivenconditionsbetweentwotables.Forexample,ifwehavethedepartmentIDofeachemployee,thenwecanusethisdepartmentIDoftheemployeetabletojoinwiththedepartmentIDofdepartmenttabletolookupdepartmentnames. UNIONoperationallowsustoadd2similardatasetstocreateresultingdatasetthatcontainsallthedatafromthesourcedatasets.Uniondoesnotrequireanyconditionforjoining.Forexample,ifyouhave2employeetableswithsamestructure,youcanUNIONthemtocreateoneresultsetthatwillcontainalltheemployeesfrombothofthetables. SELECT*FROMEMP1 UNION SELECT*FROMEMP2; ANSWER QUESTION 27
  • 29. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisthedifferenceamongUNION,MINUSandINTERSECT? 29 QUESTION UNIONcombinestheresultsfrom2tablesandeliminatesduplicaterecordsfromtheresultset. MINUSoperatorwhenusedbetween2tables,givesusalltherowsfromthefirsttableexcepttherowswhicharepresentinthesecondtable. INTERSECToperatorreturnsusonlythematchingorcommonrowsbetween2resultsets. ANSWER QUESTION 28
  • 30. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisSelfJoinandwhyisitrequired? 30 QUESTION SelfJoinistheactofjoiningonetablewithitself.SelfJoinisoftenveryusefultoconvertahierarchicalstructureintoaflatstructure ANSWER QUESTION 29
  • 31. For the hottest SQL jobs, please visit www.hirist.com hirist .com HowcanwetransposeatableusingSQL(changingrowstocolumnorvice-versa)? 31 QUESTION TheusualwaytodoitinSQListouseCASEstatementorDECODEstatement. ANSWER QUESTION 30
  • 32. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatarethedifferencesamongROWNUM,RANKandDENSE_RANK? 32 QUESTION ROW_NUMBERassignscontiguous,uniquenumbersfrom1..Ntoaresultset. RANKdoesnotassignuniquenumbers—nordoesitassigncontiguousnumbers.Iftworecordstieforsecondplace,norecordwillbeassignedthe3rdrankasnoonecameinthird,accordingtoRANK. DENSE_RANK,likeRANK,doesnotassignuniquenumbers,butitdoesassigncontiguousnumbers.Eventhoughtworecordstiedforsecondplace,thereisathird-placerecord. ANSWER QUESTION 31
  • 33. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisadatabasetransaction? 33 QUESTION Databasetransactiontakedatabasefromoneconsistentstatetoanother.Attheendofthetransactionthesystemmustbeinthepriorstateiftransactionfailsorthestatusofthesystemshouldreflectthesuccessfulcompletionifthetransactiongoesthrough. ANSWER QUESTION 32
  • 34. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatarepropertiesofatransaction? 34 QUESTION PropertiesofthetransactioncanbesummarizedasACIDProperties. 1.Atomicity:Atransactionconsistsofmanysteps.Whenallthestepsinatransactiongetscompleted,itwillgetreflectedinDBorifanystepfails,allthetransactionsarerolledback. 2.Consistency:Thedatabasewillmovefromoneconsistentstatetoanother,ifthetransactionsucceedsandremainintheoriginalstate,ifthetransactionfails. 3.Isolation:Everytransactionshouldoperateasifitistheonlytransactioninthesystem 4.Durability:Onceatransactionhascompletedsuccessfully,theupdatedrows/recordsmustbeavailableforallothertransactionsonapermanentbasis ANSWER QUESTION 33
  • 35. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisaDatabaseLock?Whatarethetypeoflocks? 35 QUESTION Databaselocktellatransaction,ifthedataiteminquestionsiscurrentlybeingusedbyothertransactions. 1.SharedLock:Whenasharedlockisappliedondataitem,othertransactionscanonlyreadtheitem,butcan'twriteintoit. 2.ExclusiveLock:Whenaexclusivelockisappliedondataitem,othertransactionscan'treadorwriteintothedataitem. ANSWER QUESTION 34
  • 36. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisaCompositeKey? 36 QUESTION ACompositeprimarykeyisatypeofcandidatekey,whichrepresentsasetofcolumnswhosevaluesuniquelyidentifyeveryrowinatable. Forexample-if"Employee_ID"and"EmployeeName"inatableiscombinedtouniquelyidentifiesarowitscalledaCompositeKey. ANSWER QUESTION 35
  • 37. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisaCompositePrimaryKey? 37 QUESTION ACompositeprimarykeyisasetofcolumnswhosevaluesuniquelyidentifyeveryrowinatable.Whatitmeansisthat,tablewhichcontainscompositeprimarykeywillbeindexedbasedoncolumnsspecifiedintheprimarykey. ThiskeywillbereferredinForeignKeytables. Forexample-ifcombinedeffectofcolumns,"Employee_ID"and"EmployeeName"inatableisrequiredtouniquelyidentifiesarow,itscalledaCompositePrimaryKey.Inthiscase,boththecolumnswillberepresentedasprimarykey. ANSWER QUESTION 36
  • 38. For the hottest SQL jobs, please visit www.hirist.com hirist .com DefineSQLInsertStatement? 38 QUESTION SQLINSERTstatementisusedtoaddrowstoatable.Forafullrowinsert,SQLQueryshouldstartwith―insertinto―statementfollowedbytablenameandvaluescommand,followedbythevaluesthatneedtobeinsertedintothetable.Insertcanbeusedinseveralways: 1.Toinsertasinglecompleterow 2.Toinsertasinglepartialrow ANSWER QUESTION 37
  • 39. For the hottest SQL jobs, please visit www.hirist.com hirist .com DefineSQLUpdateStatement? 39 QUESTION SQLUpdateisusedtoupdatedatainaroworsetofrowsspecifiedinthefiltercondition. ThebasicformatofanSQLUPDATEstatementis,UpdatecommandfollowedbytabletobeupdatedandSETcommandfollowedbycolumnnamesandtheirnewvaluesfollowedbyfilterconditionthatdetermineswhichrowsshouldbeupdated. ANSWER QUESTION 38
  • 40. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatarewildcardsusedindatabaseforPatternMatching? 40 QUESTION SQLLikeoperatorisuserforpatternmatching.SQL'Like'commandtakesmoretimetoprocess.Sobeforeusinglikeoperator,considersuggestionsgivenbelowonwhenandwheretousewildcardsearch. 1)Don'toverusewildcards.Ifanothersearchoperatorwilldo,useitinstead. 2)Whenyoudousewildcards,trynottousethematthebeginningofthesearchpattern,unlessabsolutelynecessary.Searchpatternsthatbeginwithwildcardsaretheslowesttoprocess. 3)Paycarefulattentiontotheplacementofthewildcardsymbols.Iftheyaremisplaced,youmightnotreturnthedatayouintended ANSWER QUESTION 39
  • 41. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisCrossJoin? 41 QUESTION CrossJoinwillreturnallrecordswhereeachrowfromthefirsttableiscombinedwitheachrowfromthesecondtable. ANSWER QUESTION 40
  • 42. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisaview? 42 QUESTION Viewsarevirtualtables.Unliketablesthatcontaindata,viewssimplycontainqueriesthatdynamicallyretrievedatawhenused. ANSWER QUESTION 41
  • 43. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisamaterializedview? 43 QUESTION Materializedviewsisalsoaviewbutarediskbased.Materializedviewsgetupdatedonspecificduration,baseupontheintervalspecifiedinthequerydefinition.Wecanindexmaterializedview. ANSWER QUESTION 42
  • 44. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whataretheadvantagesanddisadvantagesofviewsinadatabase? 44 QUESTION Advantages: 1.Viewsdoesn'tstoredatainaphysicallocation. 2.Viewcanbeusetohidesomeofthecolumnsfromthetable 3.ViewscanprovideAccessRestriction,sincedatainsertion,updateanddeletionisnotpossibleontheview. Disadvantages: 1.Whenatableisdropped,associatedviewbecomeirrelevant. 2.Sinceviewarecreatedwhenaqueryrequestingdatafromviewistriggered,itsbitslow 3.Whenviewsarecreatedforlargetables,itoccupymorememory. ANSWER QUESTION 43
  • 45. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhendoyouuseUPDATE_STATISTICScommand? 45 QUESTION Thiscommandisusedwhenalargeprocessingofdatahasoccurred.Ifanylargeamountofdeletions,anymodifications,orBulkCopyintothetableshasoccurred,ithastoupdatetheindexestotakethesechangesintoaccount.UPDATE_STATISTICSupdatestheindexesonthesetablesaccordingly. ANSWER QUESTION 44
  • 46. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisanIDENTITYcolumnininsertstatements? 46 QUESTION IDENTITYcolumnisusedintablecolumnstomakethatcolumnasAutoincrementalnumberorasurrogatekey. ANSWER QUESTION 45
  • 47. For the hottest SQL jobs, please visit www.hirist.com hirist .com HowwillIretrieveallrecordsofemployment1thoseshouldnotbepresentnemployment2? 47 QUESTION (Select*fromemployment2)-(Select*fromemployment1). ANSWER QUESTION 46
  • 48. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhichTCP/IPportdoesSQLServerrunon?Howcanitbechanged? 48 QUESTION SQLServerrunsonport1433.ItcanbechangedfromtheNetworkUtilityTCP/IPproperties. ANSWER QUESTION 47
  • 49. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisSQLServerAgent? 49 QUESTION SQLServeragentplaysanimportantroleintheday-to-daytasksofadatabaseadministrator(DBA).ItspurposeistoeasetheimplementationoftasksfortheDBA,withitsfull-functionschedulingengine,whichallowsyoutoscheduleyourownjobsandscripts. ANSWER QUESTION 48
  • 50. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhichcommandusingQueryAnalyzerwillgiveyoutheversionofSQLserverandoperatingsystem? 50 QUESTION SELECTSERVERPROPERTY('productversion'),SERVERPROPERTY('productlevel')andSERVERPROPERTY('edition') ANSWER QUESTION 49
  • 51. For the hottest SQL jobs, please visit www.hirist.com hirist .com HowtocreaterecursivequeryinSQLServer? 51 QUESTION RecursivequerycanbecreateinSQLusingstoredprocedurebutyoucanalsouseCTE(Commontableexpression).ItmightbealsoworthaskingaboutperformanceasCTEisnotalwaysveryfast. ANSWER QUESTION 51
  • 52. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisaconstraint? 52 QUESTION Constraintcanbeusedtospecifythelimitonthedatatypeoftable.Constraintcanbespecifiedwhilecreatingoralteringthetablestatement.Sampleofconstraintare. •NOTNULL. •CHECK. •DEFAULT. •UNIQUE. •PRIMARYKEY. •FOREIGNKEY. ANSWER QUESTION 51
  • 53. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisAutoIncrement? 53 QUESTION Autoincrementkeywordallowstheusertocreateauniquenumbertobegeneratedwhenanewrecordisinsertedintothetable.AUTOINCREMENTkeywordcanbeusedinOracleandIDENTITYkeywordcanbeusedinSQLSERVER. MostlythiskeywordcanbeusedwheneverPRIMARYKEYisused. ANSWER QUESTION 52
  • 54. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisDatawarehouse? 54 QUESTION Datawarehouseisacentralrepositoryofdatafrommultiplesourcesofinformation.Thosedataareconsolidated, transformedandmadeavailablefortheminingandonlineprocessing.WarehousedatahaveasubsetofdatacalledDataMarts. ANSWER QUESTION 53
  • 55. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisuserdefinedfunctions? 55 QUESTION Userdefinedfunctionsarethefunctionswrittentousethatlogicwheneverrequired.Itisnotnecessarytowritethesamelogicseveraltimes.Instead,functioncanbecalledorexecutedwheneverneeded. ANSWER QUESTION 54
  • 56. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatarealltypesofuserdefinedfunctions? 56 QUESTION Threetypesofuserdefinedfunctionsare. a.ScalarFunctions. b.InlineTablevaluedfunctions. c.Multistatementvaluedfunctions. ANSWER QUESTION 55
  • 57. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatarealldifferenttypesofcollationsensitivity? 57 QUESTION Followingaredifferenttypesofcollationsensitivity-. •CaseSensitivity–AandaandBandb. •AccentSensitivity. •KanaSensitivity–JapaneseKanacharacters. •WidthSensitivity–Singlebytecharacteranddoublebytecharacter. ANSWER QUESTION 56
  • 58. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisOnlineTransactionProcessing(OLTP)? 58 QUESTION OnlineTransactionProcessingorOLTPmanagestransactionbasedapplicationswhichcanbeusedfordataentryandeasyretrievalprocessingofdata.Thisprocessingmakeslikeeasieronsimplicityandefficiency.Itisfaster, moreaccurateresultsandexpenseswithrespecttoOTLP. Example–BankTransactionsonadailybasis. ANSWER QUESTION 57
  • 59. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisanALIAScommand? 59 QUESTION ALIASnamecanbegiventoatableorcolumn.ThisaliasnamecanbereferredinWHEREclausetoidentifythetableorcolumn. Example-. Selectst.StudentID,Ex.Resultfromstudentst,ExamasExwherest.studentID=Ex.StudentID Here,streferstoaliasnameforstudenttableandExreferstoaliasnameforexamtable. ANSWER QUESTION 58
  • 60. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatareaggregateandscalarfunctions? 60 QUESTION Aggregatefunctionsareusedtoevaluatemathematicalcalculationandreturnsinglevalues.Thiscanbecalculatedfromthecolumnsinatable.Scalarfunctionsreturnasinglevaluebasedontheinputvalue. Example-. Aggregate–max(),count–Calculatedwithrespecttonumeric. Scalar–UCASE(),NOW()–Calculatedwithrespecttostrings. ANSWER QUESTION 59
  • 61. For the hottest SQL jobs, please visit www.hirist.com hirist .com Howcanyoucreateanemptytablefromanexistingtable? 61 QUESTION Select*intostudentcopyfromstudentwhere1=2 Here,wearecopyingstudenttabletoanothertablewiththesamestructurewithnorowscopied. ANSWER QUESTION 60
  • 62. For the hottest SQL jobs, please visit www.hirist.com hirist .com Howtofetchcommonrecordsfromtwotables? 62 QUESTION Commonrecordsresultsetcanbeachievedby-. SelectstudentIDfromstudent.<strong>INTERSECT</strong>SelectStudentIDfromExam ANSWER QUESTION 61
  • 63. For the hottest SQL jobs, please visit www.hirist.com hirist .com Howtoselectuniquerecordsfromatable? 63 QUESTION SelectuniquerecordsfromatablebyusingDISTINCTkeyword. SelectDISTINCTStudentID,StudentNamefromStudent. ANSWER QUESTION 62
  • 64. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatarethedifferentindexconfigurationsatablecanhave? 64 QUESTION Atablecanhaveoneofthefollowingindexconfigurations: 1.Noindexes 2.Aclusteredindex 3.Aclusteredindexandmanynonclusteredindexes 4.Anonclusteredindex 5.Manynonclusteredindexes ANSWER QUESTION 63
  • 65. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatarethepropertiesanddifferentTypesofSub-Queries? 65 QUESTION PropertiesofSub-Query a.Asub-querymustbeenclosedintheparenthesis. b.Asub-querymustbeputintherighthandofthecomparisonoperator,and c.Asub-querycannotcontainanORDER-BYclause. d.Aquerycancontainmorethanonesub-query. TypesofSub-Query e.Single-rowsub-query,wherethesub-queryreturnsonlyonerow. f.Multiple-rowsub-query,wherethesub-queryreturnsmultiplerows,.and g.Multiplecolumnsub-query,wherethesub-queryreturnsmultiplecolumns ANSWER QUESTION 64
  • 66. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisSQLProfiler? 66 QUESTION SQLProfilerisagraphicaltoolthatallowssystemadministratorstomonitoreventsinaninstanceofMicrosoftSQLServer.YoucancaptureandsavedataabouteacheventtoafileorSQLServertabletoanalyzelater.Forexample,youcanmonitoraproductionenvironmenttoseewhichstoredproceduresarehamperingperformancesbyexecutingtooslowly. UseSQLProfilertomonitoronlytheeventsinwhichyouareinterested.Iftracesarebecomingtoolarge,youcanfilterthembasedontheinformationyouwant,sothatonlyasubsetoftheeventdataiscollected.Monitoringtoomanyeventsaddsoverheadtotheserverandthemonitoringprocessandcancausethetracefileortracetabletogrowverylarge,especiallywhenthemonitoringprocesstakesplaceoveralongperiodoftime. ANSWER QUESTION 65
  • 67. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhataretheauthenticationmodesinSQLServer?Howcanitbechanged? 67 QUESTION WindowsmodeandMixedMode-SQLandWindows.TochangeauthenticationmodeinSQLServerclickStart, Programs,MicrosoftSQLServerandclickSQLEnterpriseManagertorunSQLEnterpriseManagerfromtheMicrosoftSQLServerprogramgroup.SelecttheserverthenfromtheToolsmenuselectSQLServerConfigurationProperties,andchoosetheSecuritypage. ANSWER QUESTION 66
  • 68. For the hottest SQL jobs, please visit www.hirist.com hirist .com Canastoredprocedurecallitselforrecursivestoredprocedure?HowmuchlevelSPnestingispossible? 68 QUESTION Yes.BecauseTransact-SQLsupportsrecursion,youcanwritestoredproceduresthatcallthemselves.Recursioncanbedefinedasamethodofproblemsolvingwhereinthesolutionisarrivedatbyrepetitivelyapplyingittosubsetsoftheproblem.Acommonapplicationofrecursivelogicistoperformnumericcomputationsthatlendthemselvestorepetitiveevaluationbythesameprocessingsteps.StoredproceduresarenestedwhenonestoredprocedurecallsanotherorexecutesmanagedcodebyreferencingaCLRroutine,type,oraggregate.Youcanneststoredproceduresandmanagedcodereferencesupto32levels. ANSWER QUESTION 67
  • 69. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisLogShipping? 69 QUESTION LogshippingistheprocessofautomatingthebackupofdatabaseandtransactionlogfilesonaproductionSQLserver,andthenrestoringthemontoastandbyserver.EnterpriseEditionsonlysupportslogshipping.Inlogshippingthetransactionallogfilefromoneserverisautomaticallyupdatedintothebackupdatabaseontheotherserver.Ifoneserverfails,theotherserverwillhavethesamedbandcanbeusedthisastheDisasterRecoveryplan.Thekeyfeatureoflogshippingisthatitwillautomaticallybackuptransactionlogsthroughoutthedayandautomaticallyrestorethemonthestandbyserveratdefinedinterval. ANSWER QUESTION 68
  • 70. For the hottest SQL jobs, please visit www.hirist.com hirist .com Name3waystogetanaccuratecountofthenumberofrecordsinatable? 70 QUESTION SELECT*FROMtable1 SELECTCOUNT(*)FROMtable1 SELECTrowsFROMsysindexesWHEREid=OBJECT_ID(table1)ANDindid<2 ANSWER QUESTION 69
  • 71. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatdoesitmeantohaveQUOTED_IDENTIFIERON?WhataretheimplicationsofhavingitOFF? 71 QUESTION WhenSETQUOTED_IDENTIFIERisON,identifierscanbedelimitedbydoublequotationmarks,andliteralsmustbedelimitedbysinglequotationmarks.WhenSETQUOTED_IDENTIFIERisOFF,identifierscannotbequotedandmustfollowallTransact-SQLrulesforidentifiers. ANSWER QUESTION 70
  • 72. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisthedifferencebetweenaLocalandaGlobaltemporarytable? 72 QUESTION 1.Alocaltemporarytableexistsonlyforthedurationofaconnectionor,ifdefinedinsideacompoundstatement,forthedurationofthecompoundstatement. 2.Aglobaltemporarytableremainsinthedatabasepermanently,buttherowsexistonlywithinagivenconnection. Whenconnectionisclosed,thedataintheglobaltemporarytabledisappears.However,thetabledefinitionremainswiththedatabaseforaccesswhendatabaseisopenednexttime. ANSWER QUESTION 71
  • 73. For the hottest SQL jobs, please visit www.hirist.com hirist .com HowGlobaltemporarytablesarerepresentedanditsscope? 73 QUESTION Globaltemporarytablesarerepresentedwith##beforethetablename.Scopewillbetheoutsidethesessionwhereaslocaltemporarytablesareinsidethesession.SessionIDcanbefoundusing@@SPID. ANSWER QUESTION 72
  • 74. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatistheSTUFFfunctionandhowdoesitdifferfromtheREPLACEfunction? 74 QUESTION STUFFfunctionisusedtooverwriteexistingcharacters.Usingthissyntax,STUFF(string_expression,start,length, replacement_characters),string_expressionisthestringthatwillhavecharacterssubstituted,startisthestartingposition,lengthisthenumberofcharactersinthestringthataresubstituted,andreplacement_charactersarethenewcharactersinterjectedintothestring.REPLACEfunctiontoreplaceexistingcharactersofalloccurrences. UsingthesyntaxREPLACE(string_expression,search_string,replacement_string),whereeveryincidenceofsearch_stringfoundinthestring_expressionwillbereplacedwithreplacement_string. ANSWER QUESTION 73
  • 75. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisCHECKConstraint? 75 QUESTION ACHECKconstraintisusedtolimitthevaluesthatcanbeplacedinacolumn.Thecheckconstraintsareusedtoenforcedomainintegrity. ANSWER QUESTION 74
  • 76. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisthedifferencebetweenUNIONandUNIONALL? 76 QUESTION UNIONstatementismainlyusedtocombinethetablesincludingtheduplicaterowsandUNIONALLcombinebutdoesnotlookforduplicaterows.Withthis,UNIONALLwillbeveryfasterthanUNIONstatements. ANSWER QUESTION 75
  • 77. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisNOTNULLConstraint? 77 QUESTION ANOTNULLconstraintenforcesthatthecolumnwillnotacceptnullvalues.Thenotnullconstraintsareusedtoenforcedomainintegrity,asthecheckconstraints. ANSWER QUESTION 76
  • 78. For the hottest SQL jobs, please visit www.hirist.com hirist .com Howtoget@@ERRORand@@ROWCOUNTatthesametime? 78 QUESTION If@@RowcountischeckedafterErrorcheckingstatementthenitwillhave0asthevalueof@@Recordcountasitwouldhavebeenreset.Andif@@Recordcountischeckedbeforetheerror-checkingstatementthen@@Errorwouldgetreset.Toget@@errorand@@rowcountatthesametimedobothinsamestatementandstoretheminlocalvariable. SELECT@RC=@@ROWCOUNT,@ER=@@ERROR ANSWER QUESTION 77
  • 79. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisaScheduledJobsorWhatisaScheduledTasks? 79 QUESTION Scheduledtasksletuserautomateprocessesthatrunonregularorpredictablecycles.Usercanscheduleadministrativetasks,suchascubeprocessing,torunduringtimesofslowbusinessactivity.UsercanalsodeterminetheorderinwhichtasksrunbycreatingjobstepswithinaSQLServerAgentjob.E.g.backupdatabase,UpdateStatsofTables.Jobstepsgiveusercontroloverflowofexecution.Ifonejobfails,usercanconfigureSQLServerAgenttocontinuetoruntheremainingtasksortostopexecution. ANSWER QUESTION 78
  • 80. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisatablecalled,ifithasneitherClusternorNon-clusterIndex?Whatisitusedfor? 80 QUESTION UnindexedtableorHeap.MicrosoftPressBooksandBookonLine(BOL)refersitasHeap.Aheapisatablethatdoesnothaveaclusteredindexand,therefore,thepagesarenotlinkedbypointers.TheIAMpagesaretheonlystructuresthatlinkthepagesinatabletogether.Unindexedtablesaregoodforfaststoringofdata.Manytimesitisbettertodropallindexesfromtableandthendobulkofinsertsandtorestorethoseindexesafterthat. ANSWER QUESTION 79
  • 81. For the hottest SQL jobs, please visit www.hirist.com hirist .com CanSQLServerslinkedtootherserverslikeOracle? 81 QUESTION SQLServercanbelinkedtoanyserverprovidedithasOLE-DBproviderfromMicrosofttoallowalink.E.g.OraclehasanOLE-DBproviderfororaclethatMicrosoftprovidestoadditaslinkedservertoSQLServergroup. ANSWER QUESTION 80
  • 82. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisBCP?Whendoesitused? 82 QUESTION BulkCopyisatoolusedtocopyhugeamountofdatafromtablesandviews.BCPdoesnotcopythestructuressameassourcetodestination.BULKINSERTcommandhelpstoimportadatafileintoadatabasetableorviewinauser-specifiedformat. ANSWER QUESTION 81
  • 83. For the hottest SQL jobs, please visit www.hirist.com hirist .com Howtoimplementone-to-one,one-to-manyandmany-to-manyrelationshipswhiledesigningtables? 83 QUESTION One-to-Onerelationshipcanbeimplementedasasingletableandrarelyastwotableswithprimaryandforeignkeyrelationships.One-to-Manyrelationshipsareimplementedbysplittingthedataintotwotableswithprimarykeyandforeignkeyrelationships.Many-to-Manyrelationshipsareimplementedusingajunctiontablewiththekeysfromboththetablesformingthecompositeprimarykeyofthejunctiontable. ANSWER QUESTION 82
  • 84. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisanexecutionplan?Whenwouldyouuseit?Howwouldyouviewtheexecutionplan? 84 QUESTION AnexecutionplanisbasicallyaroadmapthatgraphicallyortextuallyshowsthedataretrievalmethodschosenbytheSQLServerqueryoptimizerforastoredprocedureorad-hocqueryandisaveryusefultoolforadevelopertounderstandtheperformancecharacteristicsofaqueryorstoredproceduresincetheplanistheonethatSQLServerwillplaceinitscacheandusetoexecutethestoredprocedureorquery.FromwithinQueryAnalyzerisanoptioncalled"ShowExecutionPlan"(locatedontheQuerydrop-downmenu).Ifthisoptionisturnedonitwilldisplayqueryexecutionplaninseparatewindowwhenqueryisranagain. ANSWER QUESTION 83
  • 85. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatarethetwoauthenticationmodesinSQLServer? 85 QUESTION Therearetwoauthenticationmodes– •WindowsMode •MixedMode ModescanbechangedbyselectingthetoolsmenuofSQLServerconfigurationpropertiesandchoosesecuritypage. ANSWER QUESTION 84
  • 86. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisCOALESCEinSQLServer? 86 QUESTION COALESCEisusedtoreturnfirstnon-nullexpressionwithinthearguments.Thisfunctionisusedtoreturnanon- nullfrommorethanonecolumninthearguments. Example– SelectCOALESCE(empno,empname,salary)fromemployee; ANSWER QUESTION 85
  • 87. For the hottest SQL jobs, please visit www.hirist.com hirist .com HowexceptionscanbehandledinSQLServerProgramming? 87 QUESTION ExceptionsarehandledusingTRY—-CATCHconstructsanditishandlesbywritingscriptsinsidetheTRYblockanderrorhandlingintheCATCHblock. ANSWER QUESTION 86
  • 88. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisthepurposeofFLOORfunction? 88 QUESTION FLOORfunctionisusedtoroundupanon-integervaluetothepreviousleastinteger.ExampleisgivenFLOOR(6.7) Returns6. ANSWER QUESTION 87
  • 89. For the hottest SQL jobs, please visit www.hirist.com hirist .com Canwechecklocksindatabase?Ifso,howcanwedothislockcheck? 89 QUESTION Yes,wecanchecklocksinthedatabase.Itcanbeachievedbyusingin-builtstoredprocedurecalledsp_lock. ANSWER QUESTION 88
  • 90. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatistheuseofSIGNfunction? 90 QUESTION SIGNfunctionisusedtodeterminewhetherthenumberspecifiedisPositive,NegativeandZero.Thiswillreturn+1,-1or0. Example:SIGN(-35)returns-1 ANSWER QUESTION 89
  • 91. For the hottest SQL jobs, please visit www.hirist.com hirist .com HowistheSUBSTRkeywordusedinSQL? 91 QUESTION SUBSTRisusedforstringmanipulationwithcolumnname,firstpositionandstringlengthusedasarguments.E.g. SUBSTR(NAME,13)referstothefirstthreecharactersinthecolumnNAME. ANSWER QUESTION 90
  • 92. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisaNULLvalue?WhataretheprosandconsofusingNULLS? 92 QUESTION ANULLvaluetakesuponebyteofstorageandindicatesthatavalueisnotpresentasopposedtoaspaceorzerovalue.It'stheDB2equivalentofTBDonanorganizationalchartandoftencorrectlyportraysabusinesssituation. Unfortunately,itrequiresextracodingforanapplicationprogramtohandlethissituation. ANSWER QUESTION 91
  • 93. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisasynonym?Howisitused? 93 QUESTION Asynonymisusedtoreferenceatableorviewbyanothername.Theothernamecanthenbewrittenintheapplicationcodepointingtotesttablesinthedevelopmentstageandtoproductionentitieswhenthecodeismigrated.ThesynonymislinkedtotheAUTHIDthatcreatedit. ANSWER QUESTION 92
  • 94. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisaCartesianproduct? 94 QUESTION ACartesianproductresultsfromafaultyquery.Itisarowintheresultsforeverycombinationinthejointables. ANSWER QUESTION 93
  • 95. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisatuple? 95 QUESTION StaticSQLiscompiledandoptimizedpriortoitsexecution;dynamiciscompiledandoptimizedduringexecution. ANSWER QUESTION 94
  • 96. For the hottest SQL jobs, please visit www.hirist.com hirist .com Whatisreferentialintegrity? 96 QUESTION Referentialintegrityreferstotheconsistencythatmustbemaintainedbetweenprimaryandforeignkeys,i.e.everyforeignkeyvaluemusthaveacorrespondingprimarykeyvalue. ANSWER QUESTION 95
  • 97. For the hottest SQL jobs, please visit www.hirist.com hirist .com What’sthemaximumsizeofarow? 97 QUESTION 8060bytes. ANSWER QUESTION 96
  • 98. For the hottest SQL jobs, please visit www.hirist.com hirist .com HowtochangeDatabasenameinSQLserver? 98 QUESTION Usethefollowingcode: SupportedinSQLserver2000and2005 Execsp_renamedb―test‖,―test1‖ SupportedinSQLServer2005andlaterversion ALTERDatabase―test1‖ModifyName=―test‖ ANSWER QUESTION 97
  • 99. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisaCursor? 99 QUESTION AdatabaseCursorisacontrolwhichenablestraversalovertherowsorrecordsinthetable.Thiscanbeviewedasapointertoonerowinasetofrows.Cursorisverymuchusefulfortraversingsuchasretrieval,additionandremovalofdatabaserecords. ANSWER QUESTION 98
  • 100. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatareMagicTablesinSQLServer? 100 QUESTION InsertandDeletetablesarecreatedwhenthetriggerisfiredforanyDMLcommand.ThosetablesarecalledMagicTablesinSQLServer.Thesemagictablesareusedinsidethetriggersfordatatransaction. ANSWER QUESTION 99
  • 101. For the hottest SQL jobs, please visit www.hirist.com hirist .com WhatisISNULL()operator? 101 QUESTION ISNULLfunctionisusedtocheckwhethervaluegivenisNULLornotNULLinsqlserver.ThisfunctionalsoprovidestoreplaceavaluewiththeNULL. ANSWER QUESTION 100
  • 102. For the hottest SQL jobs, please visit www.hirist.com hirist .com Resources 102 http://www.itechaleart.com/2013/05/top-50-sql-question-answers_11.html https://www.katieandemil.com/sql-interview-questions-and- answers?tab=article#Question 4 http://www.dwbiconcepts.com/tutorial/24-interview-questions/190-top-20-sql- interview-questions-with-answers.html http://a4academics.com/interview-questions/53-database-and-sql/411-sql- interview-questions-and-answers-database http://narendra86.blogspot.com/2013/10/top-80-sql-query-interview- questions.html http://crackaninterview.com/sql-queries-interview-questions-answers/ http://career.guru99.com/top-50-sql-question-answers/ http://www.indiabix.com/technical/sql-server-common-questions/ http://career.guru99.com/top-50-sql-server-questions-answers/ http://www.ittestpapers.com/sql-interview-questions(25-50).html http://www.dotnetfunda.com/interviews/cat/8/sql-server http://www.careerride.com/SQLServer-Interview-Questions.aspx
  • 103. www.hirist.com SQL TOP 100 INTERVIEW QUESTIONS & ANSWERS