Use SSIS to search for temporary variable values in other tables

Source: Internet
Author: User

During the ETL process, data is inserted into a database table, and the inserted value is often read from another database. For example, the following Customer trail requires a "Project ID", which needs to be searched for in a table of another database and then returned to the "customer trail" task stream.

The configuration of the "original Project ID" of the SQL task is as follows:
 

The SQL statement is:

If exists (select * From DBO. tb_bbproject where (pj_name = @ pj_name ))
Select top 1 pj_id from DBO. tb_bbproject where (pj_name = @ pj_name );
Else
Select-1
If you directly write: Select top 1 pj_id from DBO. tb_bbproject where (pj_name = @ pj_name), SSIS reports the following error when no data is returned for this query:
The result Column cannot be filled with the single row result type. An empty result set is returned for the query.

This is because when the "result set" is set to a single row, SSIS requires that a row be returned and empty rows are not allowed.
The data type of the variable "original Project ID" that saves the result needs to be set to "object". When used elsewhere, SSIS will be automatically converted to the int type, as shown in:
Use "original Project ID" in "ole db source data source"

The query parameters required for "ole db source" must use "select * From tablename where fieldname = ?", Only the ado net source can use the @ parameter name, But it is strange that the "ado net source" (for example) query cannot set the query parameters:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.