Home > SQL Server Tips > Database Management and Administration > Extend SSIS packages with scripting and programming
SQL Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DATABASE MANAGEMENT AND ADMINISTRATION

Extend SSIS packages with scripting and programming


By Serdar Yegulalp, Contributor
11.12.2006
Rating: --- (out of 5)


Expert advice on database administration
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


SQL Server Integration Services (SSIS), Microsoft's replacement in SQL Server 2005 for Data Transformation Services (DTS), comes loaded with a broad spectrum of components for importing data and turning it into a living thing, not just something to be passively imported. But there may come a point where you find even the new spectrum of SSIS tools doesn't quite cover all the jobs you might need to do.

To that end, Microsoft provided two basic ways to extend SSIS's functionality. One method is comparatively simple for people who don't have much programming experience or don't need to write anything terribly complex; and another is sophisticated and allows a more ambitious programmer to hook deeply into SSIS and expand enormously on it.

The Simple Approach: Scripting

Most of us are probably at least passingly familiar with scripts in other contexts, and SSIS uses VB .NET to allow a programmer to script actions within an SSIS package. The scope of a script, as opposed to a custom object, is deliberately small and focused; it's for when you need something done more or less within the context of what an existing package will allow or already does.

Within an SSIS package there are two elements you can use to add scripting: the Script Task (in the Control Flow window of the Integration Services Designer application) and the Script Component (in the Data Flow window). Each is best used in slightly different circumstances.

The Script Task is something you'll want to use for general-purpose Flow Control in a package — it's more global and powerful than the Script Component, but also that much more complex. It runs outside the Data Flow of the package and isn't constrained by the way the Data Flow works, although the Script Task generally only runs when a package is tr...


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
Database Management and Administration
Password cracking tools for SQL Server
Using traces in SQL Server Profiler
Meet compliance requirements with improved database security practices
Hardening the network and OS for SQL Server security
Securing the server and database in SQL Server
How SQL Server 2008 components impact SharePoint implementations
Troubleshooting Distributed Transaction Coordinator errors in SQL Server
Achieving high availability and disaster recovery with SharePoint databases
Clearing the Windows page file and its effect on server performance
Deploying a SQL Server virtual appliance for Microsoft Hyper-V

SQL Server Interoperability
Utilize SSAS for data predictions and classification using Excel
How to create a SQL Server linked server to DB2
Export SQL Server data to an Excel file using SSIS and Visual Studio
Performance tuning for SQL Server 2005 and Exchange running on SBS
Custom VB.Net scripting in SQL Server Integration Services
Can SQL Server 2000 work on Windows 2003 platform?
Query to search text in old DTS packages in SQL Server?
Handle slowly changing dimensions with SSIS 2005 wizard
Run DTS packages within SQL Server Integration Services
SQL Server Integration Services how-to

Microsoft SQL Server 2005
End of life comes for SQL Server 2005 SP2, 2008
SQL Server Reporting Services Fast Guide
SQL Server Service Broker Tutorial and Reference Guide
Tips for tuning SQL Server 2005 to improve reporting performance
SQL Server consolidation: Why it's an optimization technique
Parent-child dimensions in SQL Server 2005 with Analysis Services MDX
Enforcing data integrity in a SQL Server database
SSIS error message due to installation problem on SQL Server 2005
Should you upgrade to SQL Server 2005 or SQL Server 2008?
Basics for working with DATETIME and SMALLDATETIME in SQL Server 2005
Microsoft SQL Server 2005 Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
CORBA  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


iggered (although you can build in exceptions). The Task also supports breakpoints and debugging, which is useful if you're writing a fairly elaborate script that has control logic or performs some kind of decision-making. One example of a Script Task could be querying Active Directory for some bit of information or talking to another data repository for data — both before running a package.

The Script Component is a lot more tightly married to the way the Data Flow works. Instead of running once during an entire package, a Script Component's main processing runs once for each row of the data being processed. Script Components also have three basic contexts they work in: data source, a data transformation, or a data destination. The Component is also a little less interactive — it doesn't support the kind of debugging that's in the Script Task, for one. Most of what you'd want to use the Script Component for would be things like row-by-row transformations, building a custom ODBC destination, or on-the-fly error handling or transformation actions that aren't handled through native SSIS functions.

The Advanced Approach: Programming with Custom Objects

As powerful as scripting can be in SSIS packages, sometimes it's simply not enough to get the job done. In some cases you may need to write (or have someone else write) a custom SSIS extension from scratch. This is not something you can do trivially; it requires an understanding of programming from the ground up. But with custom objects it's possible to use SSIS in a way that's far beyond simple automation of tasks.

For instance, if you have a data source that's simply not supported through any existing SSIS transform (i.e., some oddball proprietary data source that's no longer supported by the manufacturer), you could write a custom connection manager object to allow using that data as a native data source. Likewise, you can create custom tasks, log providers, or data flow components with the same programming libraries that are exposed through SSIS.

Each one of the above types of items is available as a base class, attribute and method set in the languages supported by SSIS: Visual Basic, C#, C++, J# and Jscript. C++, C# and VB tend to produce the best results since they tend to be broadly supported by both developers and vendors in these contexts. The idea is that the language you use shouldn't be a hindrance; they all plug into the same exposed programmatic interfaces. You can also create user interfaces for custom objects through standard Windows forms, whenever they're needed.

One extremely powerful example of the sort of thing that can be created through SSIS custom objects is a customized foreach enumerator. Let's say you want to create a set of programming classes to perform tasks for each set of objects in a collection, such as a set of tables in a database. If you want to implement such actions in a broad variety of contexts without reinventing the wheel each time, this is one of the best ways to do it. It's especially useful if you've created a custom connection manager to some new type of data (as per the above example) and want to create custom foreach actions to go with it.

Conclusion

The path you take to extending SSIS, whether it is scripting or programming, is always going to be dictated by both your needs and your abilities. Because you can use both approaches — even at the same time! — you don't have to devote yourself any more than is needed for the task at hand. You can mix and match as required, too.

For further examples you can of course look at the links above (which go to Microsoft's own documentation of SSIS package extensions), although they're a little light on specific implementations and examples. There's also some blogs that cover the subject: Peter DeBetta's SQL Programming Blog, for instance. I can also recommend the SSIS Junkie blog, which has a good deal of ongoing discussion of how to accomplish things in SSIS (both programmatically, and otherwise!).

ABOUT THE AUTHOR:   

Serdar Yegulalp is editor of the Windows Power Users Newsletter. Check it out for the latest advice and musings on the world of Windows network administrators -- and please share your thoughts as well!
Copyright 2006 TechTarget

More from SearchSQLServer.com

  • SQL Server Integration Services programming basics
  • SQL Server Integration Services: Simplify database maintenance
  • Migrating SQL 2000 DTS packages to SSIS

  • Rate this Tip
    To rate tips, you must be a member of SearchSQLServer.com.
    Register now to start rating these tips. Log in if you are already a member.




    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



    SQL Server Development - .NET, C#, T-SQL, Visual Basic
    HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




    All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts