Execute SQL Task


The Execute SQL task will execute one or a series of SQL statements or stored procedures. The task has been greatly improved in SSIS and now allows you to execute scripts that are in a file. Most of the configuration this time is in the General page (shown in Figure 3-1). The Timeout option specifies the number of seconds before the task will time-out. A value of 0 means it can run for an infinite amount of time.

image from book
Figure 3-1

The ResultSet option sets what format you'd like the results of the query to be outputted in. By default, the results of the query will be ignored by setting the option to none. This is great when you want the SQL statement to prepare a staging table. You can also output the results to a single row, full result set, or XML format. Once you set this option to something other than none, you'll be able to map where you want the results to go in the Result Set page. This page maps the result set to a user parameter and lets you create a new one. The variable you output the results to can be in the scope of a single container or the entire package.

You can then later use those results somewhere else in your package. An example of this may be to check a value in a table that was set by another package. If the value is set to 1, that package has completed and you can proceed to the next task. Otherwise, you may loop back to the beginning of the package and try again.

The ConnectionType option, as its name implies, specifies what type of connection you'd like to run your SQL query against. Valid options include OLE DB, ODBC, ADO, ADO.NET, EXCEL, and SQLMOBILE. For SQL Server connections, select OLE DB and specify the Connection Manager below in the Connection option. Your query can be stored as a variable or input file or it can be directly inputted. You can specify the location of your SQL query under the SQLSourceType option. Then type or select the query or source of the query in the next option down. That next option may be called SQLStatement if you selected direct input in the SQLSourceType option. The option may also be called SourceVariable or FileConnection.

If you have selected the ADO connection type, then the IsQueryStoredProcedure option, which specifies whether the query is a stored procedure, will also be available. If you're not using the ADO connection type, then there's no reason to set this option. If your OLE DB source supports prepared queries, then you can select the BypassPrepare option to have this step bypassed (if set to true). Preparing a query will cache the query and its execution plan to help speed it up the next time it runs. You also have the option to parse the query or build a query by clicking these options at the bottom. By selecting Build Query, you have the familiar Query Builder tool in Visual Studio to develop your query in.



Professional SQL Server 2005 Integration Services
Wireless Java : Developing with Java 2, Micro Edition
ISBN: 189311550X
EAN: 2147483647
Year: 2006
Pages: 182

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net