While writing SSIS package to load one of my data warehouse tables, I encountered SSIS problem that took me some time to figure out. I noticed that in the dataflow task one of the OLE DB source components was not returning any data even I know that records were there. So I did some investigation and found what was causing this issue.
I found that when following conditions are met, OLE DB Source component will not return any data:
- “OLE DB Source” component is based on the SQL Query
- SQL Query contains parameters
- SQL Query contains line that starts with comments symbol “–”
Example, this query (database “Adventure Works DW”) works:
SELECT CurrencyKey
FROM dbo.DimCurrency
WHERE CurrencyKey BETWEEN ? AND ?
But this query always returns empty result set:
SELECT CurrencyKey
FROM dbo.DimCurrency
– my comments
WHERE CurrencyKey BETWEEN ? AND ?
Here are quick steps to reproduce this issue:
- In Adventure Works DW database create new table based on the script
IF OBJECT_ID(’dbo.tmpKey’) IS NOT NULL DROP TABLE tmpKey;
CREATE TABLE tmpKey (CurrencyKey int NOT NULL);
This will be our destination table and you can delete this table after this test.
- Start BIDS and create new SSIS project and then SSIS package.
- Add OLE DB connection to Adventure Works DW database. Name it DB for simplicity.
- Add “Execute SQL” task to control flow. Change connection to DB and SQL Statement to:
IF OBJECT_ID(’dbo.tmpKey’) IS NOT NULL DROP TABLE tmpKey;
CREATE TABLE tmpKey (CurrencyKey int NOT NULL);
This way we will be able to run package multiple times.
- Add two variables to package:
Name: MinID Type: Int32 value 1
Name: MaxID Type: Int32 value 2 - Add data flow task and connect it to go after “Execute SQL” task.
- Double click on data flow task to go into data flow area.
- Add “OLE DB source” and “OLE DB destination” components. Make connection from “OLE DB Source” to “OLE DB Destination”
- Change “OLE DB source” properties:
Connection: DB
Data Access Mode: SQL Command
SQL Command text:
SELECT CurrencyKey
FROM dbo.DimCurrency
WHERE CurrencyKey BETWEEN ? and ? - For “OLE DB Source” component click on “Parameters” button and map parameters:
Parameter0 User::MinID
Parameter1 User::MaxID - Change “OLE DB Destination” properties
Connection: DB
Data access mode: “Table or view - fast load”
Name of the table or the view: “dbo.tmpKey”
Click on Mappings and map “CurrencyKey” to “CurrencyKey” - Add data viewer to see records moving between “OLE DB Source” and “OLE DB Destination”
- Save and execute package. You will see 2 rows moved between source and destination. That is correct behaviour.
- Now change “OLE DB Source” SQL command text to:
SELECT CurrencyKey
FROM dbo.DimCurrency
– my comment line
WHERE CurrencyKey BETWEEN ? and ? - Save and execute package. No data will be moved. That I believe is a bug.
I submitted this issue to Microsoft connect website:
https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=298046
Of course, workaround for this problem is to remove line that starts with comments.
Mar 14th, 2008 update. Microsoft reply:
The problem that you have described is an issue with the SQL Server Native Client provider. This problem occurs with a parameterized SQL query using in SSIS components such as the OLE DB Source, when the query contains a comment line that begins with the comment characters “–”. The OLE DB Source does not parse the SQL statement (because it must support the varying SQL syntax of various data sources) and cannot catch the problem. The only solution is to omit comments from parameterized SQL statements used in the OLE DB Source.



Hello Vidas,
this is very helpful for me.
Just a few days ago i had the same issue.
I moved all OLEDB Tasks to ADO.NET.
Now I know why.
Best regards
Jörg
Hi Vidas,
I’m curious to know if the same issue occurs if you use the block comment syntax?
eg. /* my comment line */
Hi Darren,
Tested this as you suggested with block comments:
SELECT CurrencyKey
FROM dbo.DimCurrency
/* my comment line */
WHERE CurrencyKey BETWEEN ? and ?
This works no problem, so that is good to know.
Sounds suspiciously like the OLEDB Task is stripping out whitespace (including line breaks) before it executes. It’s strange that it does not throw an error.
I was stuck with connectvity problem from SSIS when executing SQL task that connects to Oracle database.
i keep getting the error
I’m running on SQLserver2005 on 64bit Win 2003 SP2.
I have one SSIS package which reads and writes data from (and to) Oracle database.
I tried with OLEDB and ODBC, I can connect and sucessfully test (while creating the connection) from BIS, but
when I attempt to execute the package in BIS, I get the error
[Execute SQL Task] Error: Failed to acquire connection “dw.world.cud”. Connection may not be configured correctly or you may not have the right permissions on this connection.
I’ve read somewhere,that its compatibility of 64bit oracle driver problem , while oracle donot have 64bit, BIS try to connect thru 64bit. So, later on I tried using dtsrun.exe in \program Files x86 \… however this time
get below error.
C:\ProgramFilesx86\Microsoft SQL Server\80\Tools\Binn>DTSRun /F D:\
N\PROJECTS\usage\USAGE_DATA.dtsx
DTSRun: Loading…
Error: -2147220220 (80040504); Provider Error: 0 (0)
Error string: The specified file is not a Package Storage File.
Error source: Microsoft Data Transformation Services (DTS) Package
Help file: sqldts80.hlp
Help context: 704
Can someone advise , how can I connect from 64bit machine via SSIS to an remote oracle instance ?.
note : The same package works fine in 34 bit environment & I can connect to oracle, however our actual servers are 64 bit.
SSIS OLE DB Source returns empty set when it is based on the SQL Query
when we using query
select…
from..
where Changecontrol > cast(cast(? as bigint) as binary(8))
what is the issue ?
we are getting the result for the same query when we running in management studio.
OLEDB continue to haunt :-(
All, I’m trying is to just read from a excel and write into a Oracle table.
I’ve a simple package that does that, when I attempt to execute on 32 bit machine. it loads without any problem.
When I take the same package and execute in 64bit platform, it simply fails with message
Error:
SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.
The AcquireConnection method call to the connection manager “DestinationConnectionOLEDB” failed with error code 0xC0202009.
I’m just curious is someone EVER successfully loaded data into Oracle using OLEDB ?
Thanks
Brian