I follow steps at http://msdn.microsoft.com/en-us/library/bb895315.aspx to implement incremental load. According to the last of the step1 , I declared a string variable in SSDT, and assign a string to it as SqlString='select * from CustomizedFunction(Argument1,Argument2,Argument3)' SqlString is good since I've print it out in SSMS.
However, when SqlString is accessed in a OLEDB Data Source of a Data Flow. Error occurs
Hresult:0xC0202009 ERROR at Data Flow Task-LoadData[OLEDB Source[1]]:SSIS Error Code DTS_E_OLEEBERROR. An OLEDB error has occured. Error Code:0x80040E0C. An OLEDB record is available. Source:"Microsoft SQL Server Native Client11.0" HResult:0x80040E0C Description:"Command text was not set for the command object."
I don't understand how did you print the variable in SSMS which is declared in SSIS.
You have to declare a variable in SSIS as a string and build your SQL command using *Exression*s if the parameters for your table valued function is dynamic.
While configuring OLEDB source you have choose the Option "SQL Command from Variable" in Data Access mode and select the variable "SqlString".
SSIS OLE DB Source must have an initial column definition in order to work. When you use 'SQL Command from Variable', you need to provide this column definition.
Let me start with a general application of the concept. Then I will address your particular scenario.
General Case
In some cases, you may have a string variable that has no initial value, and at some point in the process, the value is assigned. In this scenario, an initial value MUST be provided. One way to do this is to use a dummy query that provides the columns and data types.
For example, set the initial value of your variable to something like:
SELECT CAST('' AS VARCHAR(10) AS MyColumn1, 0 AS MyInteger FROM MyTable WHERE 1= 2
This query will never return results, but it provides the column definition that the OLE DB Source needs. At some point before the OLE DB Source executes, you'll need to assign the actual query to the variable.
Specific Case
Your case is similar, but slightly different. In your particular case, you have this query:
SqlString='select * from CustomizedFunction(Argument1,Argument2,Argument3)'
OLE DB Source has no idea what the column definitions are with SELECT *
. You need to replace SELECT *
with the actual column names and their data types.
SqlString='SELECT CAST(MyColumn1 AS VARCHAR(10)) AS MyColumn1, CAST(MyColumn2 AS INT) AS MyColumn2 FROM CustomizedFunction(Argument1,Argument2,Argument3)'
I am added an updated answer based on a recent experience with this issue.
After the steps for aliasing all the columns (giving each column a column header) we had to go through the additional step of setting 'Validate External Metadata' to false in the advanced editor for the SSIS task. Once that was done, the error was removed for us.
I am leaving this here as additional help for future users that encounter this issue.
User contributions licensed under CC BY-SA 3.0