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: