For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
AbouttheAuthors... xvii
AbouttheTechnicalReviewer ... xviii
Chapter1:IntroducingIntegrationServices...1
Chapter2:BIDSandSSMS...11
Chapter3:HelloWorld—YourFirstSSIS2012Package...43
Chapter4:ConnectionManagers...83
Chapter5:ControlFlowBasics...107
Chapter6:AdvancedControlFlowTasks ...163
Chapter7:SourceandDestinationAdapters...203
Chapter8:DataFlowTransformations ...245
Chapter9:Variables,Parameters,andExpressions...325
Chapter10:Scripting...361
Chapter11:EventsandErrorHandling...405
Chapter12:DataProfilingandScrubbing ...427
Chapter13:LoggingandAuditing ...465
Chapter14:HeterogeneousSourcesandDestinations...487
Chapter15:DataFlowTuningandOptimization ...511
Chapter16:Parent-ChildDesignPattern...525
Chapter17:DimensionalDataETL...543
Chapter18:BuildingRobustSolutions ...561
Chapter19:DeploymentModel...579
C H A P T E R 1
Introducing Integration Services
I’mthegluethatholdseverythingtogether.
importanttounderstandjustwhatETLis.Aswehavestated,ETLisanacronymforextract,transform, andload,whichisaveryliteraldescriptionofmoderndatamanipulationandmovementprocesses. WhenwetalkaboutETL,wearespecificallytalkingabout(1)extractingdatafromasource,suchasa databaseorflatfiles;(2)transformingdata,ormanipulatingandenrichingitenroutetoitsdestination; and(3)loadingdataintoitsdestination,oftenadatabase.Sowe’llbeginourjourneyintoSSISbylookingathowETLhasevolvedintheSQLServerworld.Up toSQLServer6.5,thebulkcopyprogram(bcp)wastheprimarytoolforloadingdataintoSQLServer databases.Acommand-lineutility,bcpmadeloadingbasictextfilesintodatabasetablesfairlysimple.
SSISinSQLServer12representsthefirstmajorenhancementtoSSISsinceitsintroductionway backin2005.Inthisnewestrelease,Microsofthasimplementedmajorimprovementsinfunctionality andusability.SomeofthenewgoodnessincludestheabilitytomoveETLpackagesseamlesslybetween environments,centralizedstorageandadministrationofSSISpackages,andahostofusability
enhancements.Inthisbook,you’llexplorethecorefunctionalityyouneedtogetupandrunningwith SSISandtheadvancedfunctionalityyouneedtoimplementthemostcomplexETLprocessing.
ETL: THE LOST YEARS
CHAPTER1INTRODUCINGINTEGRATIONSERVICES
Extractingdatafromawidevarietyofsourcesincludingflatfiles,XML,the Internet,MicrosoftExcelspreadsheets,andrelationalandnonrelational
databases.Ifthestocksourceadaptersdon’tcoveryourneeds,SSIS’ssupportfor .NETgivesyoutheabilitytoextractdatafromliterallyanydatasourcethatyou haveaccessto.
Validatingdataaccordingtopredefinedrulesyouspecifyasitmovesthrough yourETLprocess.Youcanvalidatedatabyusingavarietyofmethodssuchas ensuringthatstringsmatchpatternsandthatnumericvaluesarewithinagiven range.
PerformingDatacleansing,ortheprocessofidentifyinginvaliddatavaluesand removingthemormodifyingthemtoconformtoyourpredefinedconstraints. Examplesincludechangingnegativenumberstozeroorremovingextra whitespacecharactersfromstrings.
Deduplicatingdata,whichistheeliminationofdatarecordsthatyouconsiderto beduplicates.Foragivenprocess,youmayconsiderentirerecordsthatarevalue-for-valuematchestobeduplicates;forotherprocesses,youmaydeterminethata valuematchonasinglefield(orsetoffields),suchasTelephoneNumber, identifiesaduplicaterecord.
Loadingdataintofiles,databasessuchasSQLServer,orotherdestinations.SSIS providesawiderangeofstockdestinationadaptersthatallowyoutooutputdata
You’veseenusrefertoSSISasanenterpriseETLsolutioninthischapter,andyoumayhaveasked yourself,“WhatisthedifferencebetweenanenterpriseETLsolutionandanyotherETLsolution?”Don’t worry,it’sacommonquestionthatweaskedonceandthathassincebeenaskedofusseveraltimes.It hasaverysimpleanswer:enterpriseETLsolutionshavetheabilitytohelpyoumeetyournonfunctional requirementsinadditiontothestandardfunctionalrequirementsofextract,transform,andload.
SowhatisanonfunctionalrequirementandwhatdoesithavetodowithETL?Ifyou’veeverbeenon adevelopmentprojectforanapplicationorbusinesssystem,you’reprobablyfamiliarwiththeterm.In theprevioussection,wediscussedhowSSIShelpsyoumeetyourETLfunctionalrequirements—those requirementsofasystemthatdescribewhatitdoes.InthecaseofETL,thefunctionalrequirementsare generallyprettysimple:(1)getdatafromoneormoresources,(2)manipulatethedataaccordingto somepredefinedbusinesslogic,and(3)storethedatasomewhere.
security,scalability,reliability,andoverallqualityofanETLsolution.Weliketothinkofnonfunctional requirementsastheaspectsofthesystemthatdonotnecessarilyhaveadirecteffectontheendresultor outputofthesystem;insteadtheyworkbehindthescenesinsupportoftheresultgeneration.
HerearesomeofthewaysSSIScanhelpyoumeetyournonfunctionalrequirements:
RobustnessisprovidedinSSISprimarilythroughbuilt-inerror-handlingto captureanddealwithbaddataandexecutionexceptionsastheyoccur, transactionsthatensureconsistencyofyourdatashouldaprocessenteran unrecoverableprocessingexception,andcheckpointsthatallowsomeabilityto restartpackages.
Performanceandefficiencyarecloselyrelated,butnotentirelysynonymous, concepts.YoucanthinkofperformanceastherawspeedwithwhichyourETL
Maintainabilitycanbeboileddowntotheongoingcostofmanagingand administeringyourETLsolutionafterit’sinproduction.Maintainabilityisalso
SecurityisprovidedinSSISthroughavarietyofmethodsandinteractionswith othersystems,includingWindowsNTFileSystem(NTFS)andSQLServer12. PackageandprojectdeploymenttoSQLServerisapowerfulmethodofsecuring yourpackages.Inthiscase,SQLServerusesitsrobustsecuritymodeltocontrol accessto,andencryptionof,SSISpackagecontents.
ScalabilitycanbedefinedashowwellyourETLsolutioncanhandleincreasing quantitiesofdata.SSISprovidestheabilitytoscalepredictablywithyour increaseddemands,providingofcoursethatyoucreateyourpackagesto maximizeSSIS’sthroughput.WediscussscalableETLdesignpatternsinChapter 15.
CHAPTER1INTRODUCINGINTEGRATIONSERVICES
Reliability,putsimply,canbedefinedashowresistantyourETLsolutionisto failure—andiffailuredoesoccur,howwellyoursolutionhandlesthesituation. SSISprovidesextensiveloggingcapabilitiesthat,whencombinedwithBIDS’s built-indebuggingcapabilities,canhelpyouquicklytrackdownandfixtheroot causeoffailure.SSIScanalsonotifyyouintheeventofafailuresituation.
Alltheseindividualnonfunctionalrequirements,whentakentogether,helpdefinetheoverall qualityofyourETLsolution.Althoughit’srelativelysimpletoputtogetherapackageorprogramthat shuttlesdatafrompointAtopointB,thenonfunctionalrequirementsprovidealayerontopofthisbasic functionalitythatallowsyoutomeetyourservice-levelagreements(SLAs)andotherprocessing
requirements.
SSISArchitecture
OneofthemajorimprovementsthatSSISintroducedoverDTSwastheseparationoftheconceptsof
controlflowanddataflow.Thecontrolflowmanagestheorderofexecutionforpackagesandmanages communicationwithsupportelementssuchaseventhandlers.Thedataflowengineisexposedasa componentwithinthecontrolflowanditprovideshigh-performancedataextraction,transformation, andloadingservices.
AsyoucanseeinFigure1-1,therelationshipbetweencontrolflows,dataflows,andtheirrespective componentsisstraightforward.
Simplyspeaking,apackagecontainsthecontrolflow.Thecontrolflowcontainscontrolflowtasks andcontainers,bothofwhicharediscussedindetailinChapter4.TheDataFlowtaskisaspecialtypeof taskthatcontainsthedataflow.Thedataflowcontainsdataflowcomponents,whichmoveand
manipulateyourdata.Therearethreetypesofdataflowcomponents:
Sourcescanpulldatafromanyofavarietyofdatastores,andfeedthatdatainto thedataflow.
Transformationsallowyoutomanipulateandmodifydatawithinthedataflow onerowatatime.
Destinationsprovideameansforthedataflowtooutputandpersistdataafterit movesthroughthefinalstageofthedataflow.
AlthoughthesimplifieddiagraminFigure1-1showsonlyasingledataflowinthecontrolflow,any givencontrolflowcancontainmanydataflows.Asthediagramalsoillustrates,bothcontrolflowsand dataflowsarefoundwithintheconfinesofSSISpackagesthatyoucandesign,build,andtestwith MicrosoftBusinessIntelligenceDevelopmentStudio(BIDS).BIDSisashelloftheVisualStudio integrateddevelopmentenvironment(IDE)that.NETprogrammersarefamiliarwith.Figure1-2shows thedataflowforaverysimpleSSISpackageintheBIDSdesigner.
Figure1-2.SimpleSSISpackagedataflowinBIDS
CHAPTER1INTRODUCINGINTEGRATIONSERVICES
NOTE:
WeintroduceBIDSanddiscussthenewdesignerfeaturesinChapter2.
Figure1-3.SSISarchitecturalcomponents(simplified)
Atthebaseofthepyramidliethecommand-lineutilities,customapplications,theSSISdesigner, andwizardssuchastheimport/exportwizardthatprovideinteractionwithSSIS.Theseapplicationsand utilitiesaredevelopedineithermanagedorunmanagedcode.Theobjectmodellayerexposesinterfaces thatallowtheseutilitiesandapplicationstointeractwiththeIntegrationServicesruntime.The
IntegrationServicesruntime,inturn,executespackagesandprovidessupportforlogging,breakpoints anddebugging,connectionmanagementandconfiguration,andtransactioncontrol.Attheverytopof thepyramidistheSSISpackageitself,whichyoudesignandbuildintheBIDSenvironment,tocontain thecontrolflowanddataflowsdiscussedearlierinthischapter.
BYE-BYE, DATA TRANSFORMATION SERVICES
BackinSQLServer2005,MicrosoftannouncedthedeprecationofDataTransformationServices(DTS).
DTSwassupportedasalegacyapplicationinSQLServer2005,2008,and2008R2.ButbecauseSSISisa
full-fledgedenterprise-classreplacementforDTS,itshouldcomeasnosurprisethatDTSisnolonger
supportedwiththisnewestreleaseofSQLServer.ThismeansthattheExecuteDTS2000Packagetask,
theDTSruntimeandAPI,andPackageMigrationWizardareallgoingaway.Fortunately,thelearningcurve
toconvertDTSpackagestoSSISisnottoosteep,andtheprocessisrelativelysimpleinmostcases.Ifyou
havelegacyDTSpackageslyingaround,now’sthetimetoplantomigratethemtoSSIS.
NewSSISFeatures
ThereareanumberofimprovementsintheSQLServer12releaseofSSIS.Wediscussthesenewfeatures andenhancementsthroughoutthebook.Beforewedigintothedetailsinlaterchapters,weare
summarizingthenewfeatureshereforyourconvenience:
Projectdeploymentmodel:ThenewprojectdeploymentmodelisnewtoSQL Server12SSIS.ThekeyfeaturesofthisnewdeploymentmodelaretheIntegration Servicescatalog,environments,andparameters.Thenewdeploymentmodelis designedtomakedeploymentandadministrationofSSISpackagesandETL systemseasieracrossmultipleenvironments.Wediscusstheprojectdeployment modelinChapter17.
T-SQLviewsandstoredprocedures:Thenewprojectdeploymentmodel includesseveralnewSSIS-specificviewsandstoredproceduresforSQLServer.We presenttheseviewsandstoredproceduresinChapter17,duringthediscussionof theprojectdeploymentmodel.
BIDSusabilityenhancements:BIDShasbeenimprovedtomakepackage developmentandeditingsimpler.TheBIDSdesignersarenowmoreflexible,and UIenhancementssuchastheIntegrationServicestoolboxmakeiteasiertouse. WepresentthenewfeaturesinBIDSandSQLServerManagementStudio(SSMS) inChapter3.
Objectimpactanddatalineageanalysis:Theobjectimpactanddatalineage analysisfeatureprovidesmetadataforlocatingobjectdependencies—for instance,whichtablesapackagedependson.Thisnewtoolprovidesuseful informationfortroubleshootingperformanceproblemsordependencyissues,or whentakingaproactiveapproachtolocatingdependencies.Wedemonstrate impactanddatalineageanalysisinChapter12.
ImprovedMergeandMergeJointransformations:TheMergeandMergeJoin transformationshavebeenimprovedinSQLServer12SSISbyprovidingbetter internalcontrolsonmemoryusage.WecoverthenewfeaturesoftheMergeand MergeJointransformationsinChapter6.
Datacorrectioncomponent:TheDataCorrectiontransformationprovidesatool tohelpimprovedataquality.WediscussthisnewtransformationinChapter7.
Customdataflowcomponentimprovements:SQLServer12SSISincludes improvementsthatallowdeveloperstomoreeasilycreatecustomdataflow componentsthatsupportmultipleinputs.Weexplorethesenewfeaturesinthe discussionofcustomdataflowcomponentsinChapter21.
SourceandDestinationAssistants:ThenewSourceandDestinationAssistants aredesignedtoguideyouthroughthestepstocreateasourceordestination.We talkaboutthenewassistantsinChapter6.
CHAPTER1INTRODUCINGINTEGRATIONSERVICES AndywasacontributingauthorontheoriginalProfessionalSQLServer2005 IntegrationServices(Wrox,2006)book,thegoldstandardforSQLServer2005 SSIS.Andy’sblogislocatedat
http://sqlblog.com/blogs/andy_leonard/default.aspx.
JamieThomsonmaywellbeoneofthemostprolificSSISexperts.Having bloggedonhundredsofSSIStopics,JamieisaSQLServerMVPandtheoriginal
SSISJunkie.Youcanreadhisnewestmaterialat
http://sqlblog.com/blogs/jamie_thomson/orcatchuponyourSSISJunkie benefitsincludeaccesstotheSQLServerStandardmagazine.VisitPASSat www.sqlpass.orgformoreinformation.
WehighlyrecommendvisitingthesesitesasyoulearnSSISorencounterquestionsaboutbest practicesorneedguidanceonhowtoaccomplishveryspecifictasksinyourpackages.
Summary
SSISisapowerfulandflexibleenterpriseETLsolution,designedtomeetyourmostdemandingdata movementandmanipulationneeds.ThischapterintroducedsomeofthebasicconceptsofETLand howSSISfitsintotheSQLServerETLworld.WepresentedsomeofthecoreconceptsoftheSSIS architectureandtalkedaboutthenewestfeaturesinSQLServer12SSIS.Wewrappedupwithalistingof afewofourfavoritepeopleandresourcesites.InChapter2weintroduceBIDSandSSMS,withan emphasisonthenewestfeaturesdesignedtomakeyourETLpackagedesign,build,andtestingeasier thanever.
C H A P T E R 2
SQLServer12.WheninstallingSQLServer12,youhaveoptionstoinstallthreetoolsetsessentialfordeveloping ETLprocesses:BusinessIntelligenceDevelopmentStudio(BIDS),SQLServerManagementStudio (SSMS)—Basic,andManagementStudio—Complete.BIDSusestheVisualStudio2010platformforthe developmentofSSISpackagesaswellasthecreationofprojectsthatcatertothecomponentsoftheSQL Server12suite.ManagementtoolsincludeSSMS,theSQLServercommand-lineutility(SQLCMD),anda fewotherfeatures.Withthesecorecomponents,developerscanissueDataDefinitionLanguage(DDL) elementsoftheSQLServer12suite.
usingSQLServerReportingServices,SSRSprojects).Figure2-1showsthebusinessintelligenceprojects thatareavailablewithinVisualStudio.
Figure2-1.ProjectsavailablewithBIDS
ForSQLServer12,theprojectsrequiretheinstallationof.NETFramework3.5.VisualStudiosolutions canmaintainmultipleprojectsthataddressthedifferentdisciplineswithintheSQLServersuite.Afew elementscarryacrossmultipleprojects.Theseelementsarelistednext,andlogicallytietogetherata solutionlevel:
Datasourcesarethedisparatesourcesthathavethedatathatwillbeimportedby themembers.Thesesourcescanbecreatedbyusingawizardandeditedthrough thedesigner.Variouscomponentswithintheprojectcanaccessthese
connections.
Datasourceviews(DSVs)areessentiallyadhocqueriesthatcanbeusedto extractdatafromthesource.Theirmainpurposeistostorethemetadataofthe source.Aspartofthemetadata,keyinformationisalsostoredtohelpcreatethe appropriaterelationshipswithintheAnalysisServicesdatabase.
Miscellaneousisacategoryincludingallfilesthatserveasupportfunctionbutare notintegral.ThisincludesconfigurationfilesforIntegrationServices.
AnalysisServicesProject
CHAPTER2BIDSANDSSMS
Figure2-2.FolderstructureforanAnalysisServicesproject
Thesefoldersorganizethefilesinadeveloper-friendlyformat.Thisformatalsohelpswithbuilding anddeployingprojects.Apartiallistofthefoldersislistedbelow:
CubescontainsallthecubesthatarepartoftheAnalysisServicesdatabase.The dimensionscanbecreatedusingawizard,utilizingthemetadatastoredwithinthe DSVs.
MiningStructuresapplydata-miningalgorithmsonthedatafromtheDSVs.They canhelpcreatealevelofpredictiveanalysisdependingonthequalityofthedata andtheusageoftheappropriatealgorithm.YoucanusetheMiningModelWizard tohelpcreatetheseaswellastheMiningModelDesignertoeditthem.
RolescontainsallthedatabaserolesfortheAnalysisServicesdatabase.Theseroles canvaryfromadministrativepermissionstorestrictionsbasedonthedimensional data.
AssembliesholdsallthereferencestoComponentObjectModel,COM,libraries andMicrosoft.NETassemblies.
IntegrationServicesProject
TheIntegrationServicesprojecttemplateenablesthedevelopertocreateSSISpackages.Thepackageis theexecutableworkunitwithinSSIS.Itconsistsofsmallercomponentsthatcanbeexecuted
NOTE:
EventhoughVisualStudiohastheabilitytoexecutepackages,werecommendusingthecommandline
toexecutethemwhentesting.VisualStudiodebuggingmodeshouldbeusedduringdevelopment.Wediscuss
moreoptionsonrunningSSISpackagesinChapter20.
Figure2-3.FolderstructureforanIntegrationServicesproject
Thefollowinglistdescribestheobjectsandfoldersthatwillappearinyourproject:
SSISPackagescontainsallthepackagesassociatedwiththeproject.Thesework unitsaretheactualcomponentsthatwillexecutetheETL.Allthepackagesare addedtothe.dtprojfile.ThisXML-basedfilelistsallthepackagesand configurationsthatarepartoftheproject.
Miscellaneouscontainsallthefiletypesotherthanthe.dtsxfiles.Thisfolderis essentialforstoringconfigurationfilesandwillbeusefulforconsolidating connections,especiallywhenutilizingasourcecontrolapplication.Team FoundationServerisintroducedlaterinthischapter.
CHAPTER2BIDSANDSSMS
theexecution,threecolorsindicatethestatusoftheexecutableanddataflowcomponents:yellow—in
progress,red—failure,andgreen—success.Thisuseofdifferentcolorsishelpfulduringdevelopment
becauseitshowshowtheprecedenceconstraintsandtheDataFlowtasksmovethedatathrough.
NOTE:
Unlessapackagecallsanotherpackageasanexecutable,thecurrentpackageistheonlyonethatwill
runinDebugmode,notallthepackagesintheproject.VisualStudiowillopeneverypackagethatiscalledina
parent-childconfigurationandexecutethem.Iftherearetoomanypackages,certainonesmayopenwitha
MemoryOverflowerrordisplayed,butthepackagemayexecuteinthebackgroundandcontinueontothe
subsequentpackages.
TO UNDO OR REDO, THAT IS THE QUESTION
FromitsintroductioninSQLServer2005,SSISdidnothavenativeundoorredoability.Thebuttonsfor
theseoperationsexistedonthetoolbarbutwerepermanentlygrayedoutregardlessofthechangesmade
intheSSISDesigner.Themostcommonmethodtoundochangeswastoclosethepackagewithoutsaving
thosechanges.Evenwithsourcecontrol,thiswasalwaysatrickyoperationtoperform.WithSQLServer
201
2
,SSISdevelopersnowenjoyundofunctionalitythatotherVisualStudiodevelopershaveenjoyedfor
manyiterationsofthesoftware.WithSSIS,clickingtheOKbuttoncommitsthechanges.Toleavethecode
unchanged,youshouldmakeitahabittoclicktheCancelorClosebuttonifyouareonlyreviewingthe
code.Theundoandredoabilityextendstoacertainleveltotheeditingofcomponents.
ReportServerProjectWizard
TheReportServerProjectWizardallowsyoutoautomaticallycreateaReportServerproject.Youhaveto specifytheconnectionstodatasources,includingsecurityinformationifnecessary,queriesforthe reports,andsoforth.Aftertheprojecthasbeencreated,theReportDesignercanbeusedtomakeallthe modifications.
ReportServerProject
Figure2-4.FolderstructureforaReportServerproject
Thefolderscontainobjectsthatperformthefollowingtasks:
SharedDataSourcescontainsnecessarycomponentsoftheReportServer project.Thesecomponentsallowthereportstoconnecttothedatasourcesthat willbethebasisforthereports.
SharedDatasetscontainsmultiplereportsusedtosourcecommondatasets.
Reportsstoresallthe.rdlfilesthataretheactualreports.Youcanmodifythe reportsbyusingthedesigner.
TheImportAnalysisServicesDatabaseprojecttemplateautomaticallygeneratesalltheitemsofan AnalysisServicesproject.ThewizardasksyoutopointtoanAnalysisServicesdatabase.Thewizardwill reverse-engineeralltheprojectitemsbasedontheexistingdatabase.Theprojectcanbeusedtomodify theobjectsandredeploythemtotheservertoupdatethedatabase.
IntegrationServicesProjectWizard
TheIntegrationServicesProjectWizardwillautomaticallygeneratealltheitemsofanIntegration Servicesproject.Thewizardwillaskforthesourceofanexistingproject(eitherthe.dtproj fileora packagedeployedonaSQLServerinstance).Thiswizardwillimportalltheobjectsfromtheexisting project.
ReportModelProject
CHAPTER2BIDSANDSSMS
Figure2-5.FolderstructureforaReportModelproject
NOTE:
An
.smdlfilecanrefertoonlyonedatasource(
.ds)andonedatasourceview(
.dsv).Thislimitationwill
preventyoufromperformingcross-databasejoins.
Figure2-6.ModelforimportfromaDSV
DeployingtheReportModelprojectallowsendusersaccesstothedatathatispresentinthe underlyingdatabases.Theprojectneedstobedeployedtoareportserver,wheretheusershaveaccess toit.
IntegrationServices
ThebasisforenterpriseETLprocessesinSQLServer12istheSSISpackage.TheDevelopmentStudiohas undergonesomeradicalchangessinceSQLServer2008intermsoftheinterfaceandsomeperformance enhancementsinthecomponents.DevelopingpackagesbeginswithaVisualStudio2008BIDSproject. Theprojectfile(.dtproj)willbethemanagerofthepackages.Itenumeratesthepackagesthatwillbe builtanddeployed;wediscussthisprocessingreaterlengthlaterinChapter19.Theprojectfilealso assistswithdevelopmentwithinTeamFoundationServer(TFS),aVisualStudiocoderepositorysystem. SettingupTFSandworkingwithinthisframeworkofsourcecontroliscoveredinChapter20.Duringthe buildprocess,alltheconfigurationfiles(.dtsxConfig)willbecreatedaslistedineachofthepackages includedintheproject.
CHAPTER2BIDSANDSSMS Manuallyaddingordeletingpackage(.dtsx)filesinthefilesystemwillnotmodifyorupdatetheproject file.Infact,deletingpackagesfromthefilesystemwillactuallycorrupttheproject.Listing2-1
demonstratestheXMLtagsthatcanbemodifiedtoaddorremovepackagesfromtheproject.
NOTE:
WerecommendaddingexistingpackageswithinVisualStudio.However,ifapackagealreadyexistsin
theprojectfolder,acopyoftheoriginalpackagewillbecreatedandthecopywillbeaddedtotheprojectbyVisual
Studio.Usuallythecopypackagenamewillbeappendedwith“(1)”.
Listing2-1.SamplefromaProjectFile
<Database>
<Name>Integration Services Project1.database</Name>
<FullPath>Integration Services Project1.database</FullPath> </Database>
<DataSources /> <DataSourceViews />
<DeploymentModelSpecificContent> <Manifest>
<SSIS:Project SSIS:ProtectionLevel="DontSaveSensitive" xmlns:SSIS="www.microsoft.com/SqlServer/SSIS">
<SSIS:Properties>
<SSIS:Property SSIS:Name="Name">Integration Services Project1</SSIS:Property> <SSIS:Property SSIS:Name="VersionMajor">1</SSIS:Property>
<SSIS:Property SSIS:Name="VersionMinor">0</SSIS:Property> <SSIS:Property SSIS:Name="VersionBuild">0</SSIS:Property> <SSIS:Property SSIS:Name="VersionComments">
</SSIS:Property>
<SSIS:Property SSIS:Name="CreationDate">
2012-02-14T22:44:55.5341796-05:00</SSIS:Property> <SSIS:Property SSIS:Name="CreatorName">SQL12</SSIS:Property>
<SSIS:Property SSIS:Name="CreatorComputerName">SQL12</SSIS:Property> <SSIS:Property SSIS:Name="OfflineMode">0</SSIS:Property>
<SSIS:Property SSIS:Name="Description"> </SSIS:Property>
</SSIS:Properties>
<SSIS:Packages>
<SSIS:Package SSIS:Name="Package.dtsx" SSIS:EntryPoint="1" /> </SSIS:Packages>
<SSIS:Parameters />
<SSIS:DeploymentInfo> <SSIS:PackageInfo>
<SSIS:PackageMetaData SSIS:Name="Package.dtsx"> <SSIS:Properties>
<SSIS:Property SSIS:Name="ID">{A41A08A6-7C50-4DEC-B283-D76337E73505}</SSIS:Property> <SSIS:Property SSIS:Name="Name">Package</SSIS:Property>
<SSIS:Property SSIS:Name="VersionMajor">1</SSIS:Property> <SSIS:Property SSIS:Name="VersionMinor">0</SSIS:Property> <SSIS:Property SSIS:Name="VersionBuild">1</SSIS:Property> <SSIS:Property SSIS:Name="VersionComments">
</SSIS:Property>
<SSIS:Property SSIS:Name=
"VersionGUID">{9181C329-7E44-4B3D-B125-14D94639BF03}</SSIS:Property> <SSIS:Property SSIS:Name="PackageFormatVersion">6</SSIS:Property>
<SSIS:Property SSIS:Name="Description"> </SSIS:Property>
<SSIS:Property SSIS:Name="ProtectionLevel">0</SSIS:Property>
</SSIS:Properties>
<SSIS:Parameters />
</SSIS:PackageMetaData> </SSIS:PackageInfo> </SSIS:DeploymentInfo> </SSIS:Project> </Manifest>
</DeploymentModelSpecificContent> <Miscellaneous />
<Configurations>
<Configuration>
CHAPTER2BIDSANDSSMS
<Options>
<OutputPath>bin</OutputPath>
<ConnectionMappings />
<ConnectionProviderMappings /> <ConnectionSecurityMappings /> <DatabaseStorageLocations /> <ParameterConfigurationValues /> </Options>
</Configuration> </Configurations>
Thisportionofasimpleprojectfilecontainsalltheessentialelementstodevelopingandusingan SSISETLprocess.Asyoumayhaveguessed,thisinformationisstoredasExtensibleMarkupLanguage (XML).ThismakesitfeasibletomodifytheprojectdirectlybyeditingtheXML.
Wewouldliketohighlightthefollowingkeytags/properties(furtherdetailsarediscussedinlater chapters):
ProtectionLevelallowsyoutosecuresensitiveinformationsuchascredentials. Thispropertycanbesetattheprojectlevelaswellasthepackagelevel. However,bothsettingsshouldbethesame.Allthepackageswithinaproject needtohavethesameprotectionlevelsetastheprojectfilewhenbuildingthe project.WediscussthispropertyatgreaterlengthinChapter19.
Packagescontainsallthepackagesthatareassociatedwiththeproject.Copying andpastingthistagandmodifyingthenametoreflectapackagethatexistsin
Parameterscanbeusedatruntimetosetvaluesinthepackage.Thisproperty allowsforcertaincomponentsofthepackagetochangevalues.Themost notableplaceforthisisintheOLEDBsourcecomponentthatcanparameterize aSQLstatement.Parameterizingapackageiscoveredingreaterdetailin Chapter16.
Configurationdetermineswhetheryoubuildordeploytheproject.By
default,thepropertyissettobuildtheproject.Differentsettingscanbeusedfor thevariousconfigurationsthatyoucreate,dependingonthepurposeforeach configuration.TheconfigurationmanagerontheProjectSettingsallowsyouto createdifferentconfigurations.
OutputPathsetsthefolderpathtotheobjectsthatwillbebuiltfortheproject.By default,itissettothebindirectory.Whenthedeploymentutilityneedstobe created,adifferentpathcanbedefined.In2005and2008,creatingthe deploymentutilityusedthedefaultfolderpathofbin\Deployment.
ToolWindows
historyofsomeoftheprojectsthatwereopened.Atthebottomofthispanearelinkstoopenexisting
CHAPTER2BIDSANDSSMS thatareactivated(OnError,OnExecStatusChanged,andsoforth).Thetriggerscanbeattachedtoallthe executablesandtasksinthepackage.Wegiveanin-depthwalk-throughofeventhandlinginChapter10.
ThePackageExplorertabprovidesaquickglanceattheentirepackage.Itshowsallthecontentsof thepackageintreeview,asshownearlierinFigure2-8.Asyoucanseeinthefigure,thevariablesappear indifferentplaces;thisisduetothedefinedscopeofthevariable.VariablesarediscussedinChapter11.
Oneofthenewfeaturesthathasbeenaddedwithregardstovariablesistheadditionofavariable property,RaiseChangedEvent.Thisallowsforcertainchangecriteriatotriggereventsthatcanbe capturedbytheeventhandlers.ItalsoallowsforSSISloggingtocapturethiseventthroughthelog provideryouuse.Figure2-9showsthetreediagramviewoftheobjectsinapackage.
NOTE:
WhendevelopingSSISpackages,theconceptoffocusplaysanimportantrole.Focusbasicallymeans
whichcomponentiscurrentlyselected.Thisiscriticaltokeepinmindwhencreatingvariables.Havingacontainer
oranexecutableaccidentallyselectedwhencreatingavariablewilllimitittothatparticularobject.BIDSallows
youto“move”variablesbetweenscopes.However,allVisualStudiodoesiscreateanewvariableinthenew
scopewiththenameoftheoriginalvariablehavinga
1appended,andthenVisualStudiodeletestheoriginal
Figure2-9.ThePackageExplorer
Duringtheexecutionofthepackage,aProgresstabappearstotherightofthePackageExplorertab. Thistabcontinuouslyupdateswiththecurrentstateoftheexecutionprocessuntiltheendwitheithera successorfailure.Thistabwillshowwhichexecutable(s)iscurrentlyrunning,thenumberofrowsthat lookupcomponentshavecached,andmore.Italsocapturestheprogressofthepre-executeprocessing aswellasthepost-executeprocessing.Aftertheexecution,itrenamesitselftotheExecutionResultstab. TheExecutionResultstabcontainsthesameoutputastheveryendoftheProgresstab.Oneofthemost criticalpiecesofinformationstoredintheExecutionResultstabisthenumberofrowscommittedtothe destinations.
Atthetop-rightcorneroftheDesignerwindow,therearetwobuttons.Thesebuttonsareshortcuts totheParametersandVariableswindowpaneandtheSSISToolboxwindowpane.Theycomeinhandy whentryingtoquicklylookattheparametersandvariablesandthetoolsavailablefortheselected context.
ResolveReferences
CopyMappingstoClipboardcopiesthecontentsoftheentiremappingtable
CHAPTER2BIDSANDSSMS
TIP:
Bydefault,SSIS12hasitsowngroupingofcomponents,butthisgroupingcanbechangedaccordingto
yourneeds.Taskscanbemovedtotheothergroupingsbyright-clickingthecomponentandmovingittothe
desiredgrouping.Containersaretheexception;theycanbemovedonlytoFavoritesorCommon.
TheSSISToolboxforthedatalowisorganizedinasimilarfashiontothecontrolflow.The componentsaredividedintocategories:Favorites,Common,OtherTransforms,OtherSources,and OtherDestinations.Justaswiththecontrolflowtasks,thisgroupingismodifiabletoadegreefor personalpreferences.ThedefaultfavoritesforthedataflowarenewtoSSIS:theDestinationAssistant andSourceAssistant.Theseassistantsorganizetheconnectionmanagersdefinedinthepackagebytheir storagetype,asshowninFigure2-11.Bydefault,theyshowonlythedatastorageapplicationsthathave driversinstalledonthemachine.Theassistantscanbeusedtocreatenewconnectionmanagersifthe desiredonesdonotalreadyexist.
Figure2-11.DestinationAssistant
PackageCodeView
filesinSQLServer2008andinSQLServer12arevast.Theattributesforeachofthetagsisgivenona newline,makingthecodemuchmorehumanreadable.Thisfeaturealsomakesthepackages
modifiableusingdifftools.InTFS,theCompareFilestoolnowbecomesaviableoptionforidentifying differencesbetweenpackageversions.ItalsomakestheMergetoolinTFSeasiertooperatetocombine twoversionsofapackage.Listing2-2showsasamplefromanSSIS12package’sdataflowsource component.
Listing2-2.DataFlowTaskComponent
<component
refId="Package\Data Flow Task\OLE DB Source"
componentClassID="{165A526D-D5DE-47FF-96A6-F8274C19826B}" contactInfo="OLE DB Source;Microsoft Corporation;
Microsoft SQL Server; (C) Microsoft Corporation; All Rights Reserved; http://www.microsoft.com/sql/support;7"
description="OLE DB Source" name="OLE DB Source" usesDispositions="true" version="7">
<properties> <property
dataType="System.Int32"
description="The number of seconds before a
command times out. A value of 0 indicates an infinite time-out." name="CommandTimeout">0</property>
<property
dataType="System.String"
description="Specifies the name of the database object used to open a rowset." name="OpenRowset"></property>
<property
dataType="System.String"
description="Specifies the variable that contains the name of the database object used to open a rowset." name="OpenRowsetVariable"></property>
<property
dataType="System.String"
description="The SQL command to be executed." name="SqlCommand"
UITypeEditor="Microsoft.DataTransformationServices.Controls.ModalMultilineStringEditor,
Microsoft.DataTransformationServices.Controls, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91">SELECT 1 AS A WHERE 1 = 1;</property>
<property
dataType="System.String"
description="The variable that contains the SQL command to be executed." name="SqlCommandVariable"></property>
<property
CHAPTER2BIDSANDSSMS
description="Specifies the column code page to use
when code page information is unavailable from the data source." name="DefaultCodePage">1252</property>
<property
dataType="System.Boolean"
description="Forces the use of the DefaultCodePage property value when describing character data." name="AlwaysUseDefaultCodePage">false</property> <property
dataType="System.Int32"
description="Specifies the mode used to access the database." name="AccessMode"
typeConverter="AccessMode">2</property> <property
dataType="System.String"
description="The mappings between the parameters in the SQL command and variables." name="ParameterMapping">"0",{F05D0A62-4900-482A-88D9-DE0166CB4CB9};</property> </properties>
<connections>
<connection
refId="Package\Data Flow Task\OLE DB Source.Connections[OleDbConnection]" connectionManagerID="Package.ConnectionManagers[FRANKIE-VM\SQL12.SSISDB]" description="The OLE DB runtime connection used to access the database." name="OleDbConnection" />
</connections> <outputs> <output
refId="Package\Data Flow Task\OLE DB Source.Outputs[OLE DB Source Output]" name="OLE DB Source Output">
<outputColumns> <outputColumn
refId="Package\Data Flow Task\
OLE DB Source.Outputs[OLE DB Source Output].Columns[A]" dataType="i4"
errorOrTruncationOperation="Conversion" errorRowDisposition="FailComponent" externalMetadataColumnId=
"Package\Data Flow Task\OLE DB Source.Outputs [OLE DB Source Output].ExternalColumns[A]"
lineageId="Package\Data Flow Task\OLE DB Source.Outputs [OLE DB Source Output].Columns[A]"
name="A"
truncationRowDisposition="FailComponent" /> </outputColumns>
<externalMetadataColumns isUsed="True"> <externalMetadataColumn
dataType="i4"
name="A" /> </externalMetadataColumns>
</output> <output
refId="Package\Data Flow Task\OLE DB Source.Outputs[OLE DB Source Error Output]" isErrorOut="true"
name="OLE DB Source Error Output"> <outputColumns>
<outputColumn
refId="Package\Data Flow Task\OLE DB Source.Outputs [OLE DB Source Error Output].Columns[A]"
dataType="i4"
lineageId="Package\Data Flow Task\OLE DB Source.Outputs [OLE DB Source Error Output].Columns[A]"
name="A" /> <outputColumn
refId="Package\Data Flow Task\OLE DB Source.Outputs [OLE DB Source Error Output].Columns[ErrorCode]"
dataType="i4"
lineageId="Package\Data Flow Task\OLE DB Source.Outputs [OLE DB Source Error Output].Columns[ErrorCode]"
name="ErrorCode" specialFlags="1" /> <outputColumn
refId="Package\Data Flow Task\OLE DB Source.Outputs [OLE DB Source Error Output].Columns[ErrorColumn]" dataType="i4"
lineageId="Package\Data Flow Task\OLE DB Source.Outputs [OLE DB Source Error Output].Columns[ErrorColumn]" name="ErrorColumn"
specialFlags="2" /> </outputColumns>
<externalMetadataColumns /> </output>
</outputs> </component>
SomekeypointstohighlightwhenlookingthroughtheXMLofanextremelysimplesource componentincludethesimplicityofthepackageincomparisontothatofpriorversionsofSSIS,and somechangesinhowtheobjectsarenowtrackedbythepackage.Oneofthekeyreasonsforthe readabilityimprovementoftheXMListhatsomedefaultsettingsarenotgenerated.If,forexample,the IsSortedpropertyofasourcecomponentisleftatthedefaultvalueofFalse,aswasdoneinListing2-2, noextraXMLwillbegeneratedtostorethatmetadata.InpriorversionsofSSIS,allthegrittydetailsare storedintheXMLofapackage.Thefollowinglisthighlightssomeofthemoreimportantproperties:
refIdindicatesthepathtotheobjectwithinthepackage.Thisproperty uniquelyidentifiesthecomponentwithinthepackage.
CHAPTER2BIDSANDSSMS
Connectionscontainsalltheconnectioninformationstoredwithinthepackage forthedatasourcecomponent.Itispossibletosavelogincredentialsforthe package,butitisnotrecommended.Eventheconnectionmanagershave refId.
Output Columnsthemetadataabouttheoutputofthepackageisimportantto makesurethatthedataisinsertedproperly.Ifthereisafailuresimplywith convertingthedataintosomethingSQLServercanprocess,thepackagecanbe settofailasaresult.
AnotherchangethatisnoticeablejustbylookingattheXMListhewaythelineageIdistrackedin theXML.AlineageIdisusedbySSIStotrackallcolumnswithindataflows,includingtheerrorcolumns thatgetaddedtothepipelinebycomponents.Insteadofhard-codinganintegervalueaswasdonein previousversions,SSISnowusesthenamesoftheobjectstoessentiallycreateapathtoanobject,and becauseobjectshavetohaveuniquenameswithinSSIS,thepathitselfcreatestheuniqueidentifierfor thecolumns.AnothergreatimprovementinthereadabilityoftheXMLwasmadebyreplacingthe< and>entityencodingswiththeirappropriatespecialcharacters.
AnewadditiontotheXMLofthepackageisasectioncalledCDATA,whichcapturesthevisuallayout ofthecomponentsinapackage.Listing2-3demonstratesthissectionofthepackagecode.Itcaptures
<![CDATA[<?xml version="1.0"?>
<!--This CDATA section contains the layout information of the package.
The section includes information such as (x,y) coordinates, width, and height.--> <!--If you manually edit this section and make a mistake, you can delete it. -->
<!--The package will still be able to load normally but the previous layout information will be lost and the designer will automatically re-arrange the elements on the design surface.-->
<Objects
Version="sql12">
<!--Each node below will contain properties that do not affect runtime behavior.--> <Package
design-time-name="Package"> <LayoutInfo>
<GraphLayout
Capacity="4"
xmlns="clr-namespace:Microsoft.SqlServer.IntegrationServices.Designer.Model.Serialization;assembly= Microsoft.SqlServer.IntegrationServices.Graph">
<NodeLayout
Size="152.276666666667,42" Id="Package\Data Flow Task"
TopLeft="5.49999999999999,5.49999999999989" /> </GraphLayout>
design-time-name="Package\Data Flow Task"> <LayoutInfo>
<GraphLayout
Capacity="4"
xmlns="clr-namespace:Microsoft.SqlServer.IntegrationServices.Designer.Mode
l.Serialization;assembly=Microsoft.SqlServer.IntegrationServices.Graph" xmlns:mssgle="clr-namespace:Microsoft.SqlServer.Graph.LayoutEngine;assembly= Microsoft.SqlServer.Graph" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <NodeLayout
Size="151.083333333334,42"
Id="Package\Data Flow Task\OLE DB Source" TopLeft="15.918333333333,5.5" />
<NodeLayout
Size="171.920000000001,42"
Id="Package\Data Flow Task\OLE DB Destination" TopLeft="5.50000000000001,107.5" />
<EdgeLayout
Id="Package\Data Flow Task.Paths[OLE DB Source Output]" TopLeft="91.46,47.5">
<EdgeLayout.Curve> <mssgle:Curve
StartConnector="{x:Null}" EndConnector="0,60" Start="0,0"
End="0,52.5"> <mssgle:Curve.Segments> <mssgle:SegmentCollection Capacity="5"> <mssgle:LineSegment
End="0,52.5" /> </mssgle:SegmentCollection>
</mssgle:Curve.Segments> </mssgle:Curve>
</EdgeLayout.Curve> <EdgeLayout.Labels> <EdgeLabelCollection /> </EdgeLayout.Labels> </EdgeLayout>
</GraphLayout> </LayoutInfo> </TaskHost>
<PipelineComponentMetadata
design-time-name="Package\Data Flow Task\OLE DB Source"> <Properties>
<Property>
<Name>DataSourceViewID</Name> </Property>
</Properties>
CHAPTER2BIDSANDSSMS
design-time-name="Package\Data Flow Task\OLE DB Destination"> <Properties>
<Property>
<Name>DataSourceViewID</Name> </Property>
<Property>
<Name>TableInfoObjectType</Name> <Value
type="q2:string">Table</Value> </Property>
</Properties>
</PipelineComponentMetadata> </Objects>]]>
Asthedefaultcommentexplains,thisdataisstoredusing(x,y)Cartesianplanecoordinatesand widthandheightpairings,inthatpairingorder.Thehighlightedsectionshowsthecapturingofthedata flowpaths’lines.
SQLServerManagementStudio
SQLServer12’sbuilt-intoolforaccessandmaintenanceistheManagementStudio.Itallowsyouto configure,administer,anddevelopcomponentsofSQLServer.Connectingtothedatabaseengine
NOTE:
Errorsinexecutionusuallywilldisplayalinenumberwheretheerrorismostlikelytobefound.Thisline
(--)atthebeginningofeachofthecurrentorselectedlines.CHAPTER2BIDSANDSSMS setisareportfile(.rpt).
example,.sqlforSQLServer).
window,youwillseetwobuttonsthatwillallowyoutoopeneitherSQLServertemplatesorAnalysis Servicestemplates.Thetemplatesopenasnewquerywindows.
CHAPTER2BIDSANDSSMS
Afterexpandingtothetreethatyoudesire,youcanaddthetemplatetoaquerywindowbysimply double-clickingit.Afterthetemplateisopen,theSpecifyValuesforTemplateParametersbuttononthe contextmenucanbeusedtoprompttheutility.Therealpowerbehindthetemplatesisthatyoucan createyourownsetoftemplatesthatarespecifictoyourneeds.Youcanaddcommentblocksatthetop ofthescriptsthatprovidedetailsaboutthescriptanditscontents,andallofthiscanbeparameterized. Theparametershavethefollowingformat:<parameter_name, data_type, value>.Theparameter_name specifiesthenameoftheparameter,thedata_typespecifiesthedatatypeoftheparameter,andthe valuespecifiesthevaluethatwillreplaceeveryinstanceoftheparameter.
Figure2-15.SpecifyValuesforTemplateParameters
Youcanalsoaddyourtemplatestothefolderofyourchoosing.Becausemostobjectshavefolders fortheirtemplates,youarelikelytocreateatemplateinanexistingfolderratherthancreatingyourown templatefolder.
CodeSnippets
extremelyhelpfulwithVisualStudiodevelopmentandisawelcomefeatureinSQLServer12.Listing2-4 displaysacustomsnippetthatwecreatedtoscriptadropandacreatestatementforatable.
NOTE:
ThedefaultsetofsnippetsconsistmainlyofDDLandDCLobjectcreatescripts.Thisisextremelyuseful
becauseSSMSstorestheactualsyntaxthatwedevelopersmostlikelywouldusetoreferenceMicrosoft
DevelopersNetwork,MSDN,orBookOnline,BOL.Withtheabilitytocreateyourownsnippets,itislikelythat90
percentofyoureverydaysyntaxcanbecodedforthispurpose.Asidefromsyntax,commonblocksforyourqueries
(joinsyouperformonamajorityofyourqueries,
whereclausesthatarecrucialtothebusinesslogic,andsoforth)
canallbescriptedsothattheycanbeaddedtoyourcodewithafewkeystrokesratherthantypingthemoutover
andoveragain.
Listing2-4.SnippetforDropandCreateTable
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<_locDefinition xmlns="urn:locstudio"> <_locDefault _loc="locNone" />
<_locTag _loc="locData">Title</_locTag>
<_locTag _loc="locData">Description</_locTag> <_locTag _loc="locData">Author</_locTag> <_locTag _loc="locData">ToolTip</_locTag> </_locDefinition>
<CodeSnippet Format="1.0.0"> <Header>
<Title>Drop and Create Table</Title>
<Shortcut></Shortcut>
<Description>Drops a table if it exists, then creates a table.</Description> <Author>Rodrigues, Coles</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType> </SnippetTypes>
</Header> <Snippet> <Declarations>
<Literal>
<ID>SchemaName</ID>
<ToolTip>Name of the schema</ToolTip>
<Default><![CDATA[<schema_name, sysname, dbo>]]></Default> </Literal>
CHAPTER2BIDSANDSSMS
<ID>Tablename</ID>
<ToolTip>Name of the table</ToolTip> <Default>Sample_Table</Default> </Literal>
<Literal> <ID>column1</ID>
<ToolTip>Name of the column</ToolTip> <Default>ID</Default>
</Literal> <Literal>
<ID>datatype1</ID>
<ToolTip>Data type of the column</ToolTip> <Default>INT IDENTITY(1,1) NOT NULL</Default> </Literal>
<Literal> <ID>column2</ID>
<ToolTip>Name of the column</ToolTip> <Default>Desc</Default>
</Literal> <Literal>
<ID>datatype2</ID>
<ToolTip>Data type of the column</ToolTip> <Default>NVARCHAR(50) NULL</Default> </Literal>
</Declarations>
<Code Language="SQL"> <![CDATA[
IF EXISTS (
SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[$SchemaName$].[$Tablename$]') AND type in (N'U')
)
DROP TABLE [$SchemaName$].[$Tablename$]; GO
CREATE TABLE $SchemaName$.$Tablename$ ( </Code>
</Snippet> </CodeSnippet> </CodeSnippets>
TitleisthenamethatManagementStudiowillusetouniquelyidentifyyour customsnippet.Thewizardthataddssnippetstothecollectionwillforcibly renamethesnippetifitdetectsacollisionwithanexistingsnippetinthesame folderpath.
Literaldefinesthecomponentsofthesnippetthatcanbereplacedquickly. UsingtheTabkeytraversesthroughtheliteralsinthecode.Theliteralcanbe definedasadefaultvaluethatcanbesetasaparameter.Usingparametersas thedefaultvaluesforliteralsisthekeytorepurposingtheSpecifyValuesfor TemplateParametersutilityforcodesnippets.
Codecontainstheactualcodethatistobeinsertedinthescript.Thecodeblock willbeinsertedasitisintheCDATAblock.Itwillpreservethewhitespaceand replacetheliteralswiththeirspecifieddefaults. functionalityofManagementStudio,convolutedjoinsandwhereclausescanbestoredforeasyaccessto anyscript.
Summary
C H A P T E R 3
Hello World—Your First
SSIS 2012 Package
Takethefirststepinfaith.Youdon'thavetoseethewholestaircase,justtakethefirst
step.
—CivilRightsMovementleaderMartinLutherKingJr.
Inthepreviouschapter,weintroducedyoutoSQLServer12’sdevelopmenttools,BIDSandSSMS. Beforewestartdiscussingthein-depthdetails,wewillwalkyouthroughsomeexamplepackagesto
http://2010.census.gov/2010census/data/.WeusetheApportionmentandPopulationDensitydatasets inthischapter.Theonlychangewemadetothisdataistoremovesomeheaderandfooterrecordsto keeptheintroductiontodevelopingSSIS12packagessimple.Theactualdataitselfwasnotmodified.
ApportionmentreferstothedividingofthetotalseatsintheHouseoftheRepresentativesamongthe50 states,dependingontheirpopulation.PopulationDensityreportstheaveragepopulationpersquare mileofthestate.
IntegrationServicesProject
Package.dtsx.Thefirstpackagewillbecompletelyempty,andtheinitialdesignerwillshowthecontrol
NamecanbemodifiedthroughVisualStudio’sSolutionExplorer.Thebenefitsof modifyingthroughVisualStudio’sSolutionExplorerasopposedtomodifying throughthefilesystemorthepropertyfieldinthepackageincludethe automaticrecognitionbytheprojectfileandtheautomaticrenamingofthe packagenameproperty.Uponcreation,thisvalueisdefaultedtothename assignedbyVisualStudio.
DelayValidationdetermineswhetherthepackageobjectswillvalidatewhenthe packageisopenedforediting.Bydefault,thispropertyissettoFalse,meaning thatalltheobjectswillvalidatewhenthepackageisopened.Bysettingthis propertytoFalse,youwillvalidateonlyduringruntime.Thiscanbedangerous tododuringthedevelopmentphaseifthereareDataDefinitionLanguage,
IDprovidesauniqueidentifierforthepackage.Thispropertybecomes importantwhenconsideringloggingoptions.ThisIDwilldistinguishthe
CHAPTER3HELLOWORLD—YOURFIRSTSSIS2012PACKAGE havetolookthereforcertaininformation.TheannotationstringitselfisstoredintheCDATAatthe bottomofthepackageXML. enableyoutomaintainthispracticewithSSIS12inSection2ofthisbook.Thepurposecoverstheend stateaftertheexecutionofthepackage—whichdataelementshavebeenmoved,whichitemshavebeen movedaroundonthefilesystem,theexecutionofstoredprocedures,andsoforth.Thisismeanttobea high-leveldescriptionratherthanadetaileddescriptionbutessentiallywilldependonyourdesignof theETLprocess.
Parametersandvariablesarerelatedinthattheycanbeusedtopassvaluesbetweenpackages.
parentpackage,whichallowsyoutodirectlyaccessthevariable.However,thismethodalsocausesthe