问题
OK... I have a relatively simple SSIS package (DTSDesigner100, Visual Studio 2008 Version 9.0.30729.4462 QFE, .NET Framework 3.5 SP1). At the end of the SSIS control flow for the package is a File System Task which is a Rename File operation.
The properties of this File System Task are as follows:
- IsDetinationPathVariable: True
- DestinationVariable: User::OutputFileName
- OverwriteDestination: True
- Description: File System Task
- Operation: Rename file
- IsSourcePathVariable: False
- SourceConnection: Excel Template Copy Destination
There are no defined expressions. As you can see, I have the Destination assigned as a variable User::OutputFileName. So let's look at that variable...
- Name: OutputFileName
- Scope: Package
- Data Type (ValueType): String
- Value:
- Namespace: User
- EvaluateAsExpression: True
- ReadOnly: False
- Expression: (see below)
.
"\\\\SERVER\\Folder\\" + "MyAwesomeExcelWorkbook_"
+ (DT_WSTR,4)DATEPART("year", GETDATE())+ "-"
+ RIGHT("0" + (DT_WSTR,2)DATEPART("mm", GETDATE()), 2) + "-"
+ RIGHT("0" + (DT_WSTR,2)DATEPART("dd", GETDATE()), 2) + "-"
+ RIGHT("0" + (DT_WSTR,2)DATEPART("hh", GETDATE()), 2) + "-"
+ RIGHT("0" + (DT_WSTR,2)DATEPART("mi", GETDATE()), 2) + "-"
+ RIGHT("0" + (DT_WSTR,2)DATEPART("ss", GETDATE()), 2)
+ ".xlsx"
So I can Evaluate this expression successfully. Every time the package runs (and fails) its Value is the value of the evaluated expression, as one would expect.
When I run the package, here's what happens...
- The previous steps run successfully.
- The File System Task starts, and the file is successfully renamed.
- However, the package now fails since the File System Task fails with the following error:
.
Error: 0xC001F009 at Package: The type of the value being assigned to variable "User::OutputFileName" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.
Task failed: Rename Excel Workbook
Error: 0xC0019001 at Rename Excel Workbook: The wrapper was unable to set the value of the variable specified in the ExecutionValueVariable property.
Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (4) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "Package.dtsx" finished: Failure.
There is apparently some minor detail I am forgetting here. Now, I've tried casting the entire expression as a DT_WSTR,512 -- that evaluates just fine, but the File System Task will still fail with the same error.
Anyone who can point out the detail(s) I'm overlooking? Thanks in advance.
回答1:
I also encountered the same error. I was using an "Execute SQL Task" to run a stored procedure, from which the single row result set values were being used to set the SSIS package variables. The variables from the stored procedure were declared as "varchar(max)" and I was assigning them to package level variables which were defined as "string".
So I tried changing the stored procedure declarations to varchar(512) and "VOILA"... no more error. Actually... it also worked with varchar(8000) and nvarchar(4000)... but SSIS no likey varchar(max).
回答2:
The issue is the variable is scoped to the Package, and not the task.
Changing the variable to be scoped to the task results in successful execution.
EDIT: I figured I need to ask -- why? This honestly doesn't jibe with my understanding of SSIS -- which I've used since its introduction through every Denali CTP. What is going on under the hood that results in this being hunky-dory for task-scoped variables, but not package scoped ones that get used in a File System Task? Outside of certain tasks there's no issue, but there is one when I use them in certain tasks. What's going on?
回答3:
You may want to check for "extra" variables in your SSIS package. Package-scoped variables should be available at the task. Open the Variables window and click the "Show All Variables" window to see if you have two variables - at different scopes - named OutputFileName.
Since variables are identified by name in SSIS, a variable at a lower scope - say a Sequence Container containing the File System Task - will effectively intercept the variable identification of a package-scoped variable if both variables are named the same:
Hope this helps, Andy
回答4:
I'd like to add some information, this being the closest description of my current issue and hopefully it will help someone else. I am loading a recordset object from a parameterised SQL Task, then subsequently using a for each loop on the recorset and loading the fields into variables.
I recieved the above error against one of the variables that I was loading into in the for each loop.
The issue went away when I altered the prior SQL task populating the recordset.
i.e. when using this in the prior SQL Task caused an error when loading COL2 into a variable in a subsequent for each loop:
SELECT COL1, COL2 FROM Table WHERE COL2 = ? OR ? = ''
(or)
SELECT COL1, COL2 FROM Table WHERE COL2 = ? OR ? = N''
and this stopped the error occuring:
SELECT COL1, COL2 FROM Table WHERE COL2 = ?
Parameter functionality is disappointing in SSIS.
- Can't put parameters in the select part
- Can't wrap a conversion function around a parameter
- Can't use parameters within UDF's or any query of appreciable complexity
- Need to look up esoteric parameter codes depending on the driver (OLEDB/ADO.Net/ODBC)
- From the above error it appears that using a field for a parameter somehow affects the metatada on the field output from query.
回答5:
I am getting the following exception. I have resolved it. I will explain the issue and steps which I have taken for solving the issue.
**Error Message :** The type of the value being assigned to
variable differs from the current variable type..
**When :** Executing SSIS package. SSIS package is calling batch script.
Batch script is calling Python script. SSIS package is expecting output from
batch file. After executing the batch file and python script output
should be delivered to SSIS package. But Here I am getting the exception.
**Python Script writing output into stdout :**
//Python code start
print >>sys.stdout, "output"
//Python code End
So here the output is written to standard out.
**Issue :** When I am calling the batch file, I am writing the log
into one log file.
Please check the following batch script.
//Batch File script start
C:\Python25\python.exe GetValFromPYthonSCript.py > scriptLog.txt
//Batch File script End
So what happend is, the output is written in the log.But again
I tried to read the output using the following line in SSIS.
//SSIS coding start
Dim objProcess As Process
objProcess = New Process()
objProcess.StartInfo.FileName = "batchFile location"
objProcess.start()
System.Windows.Forms.MessageBox.Show(objProcess.StandardOutput.ReadLine())
//SSIS coding End
So when I am trying to display I am getting the above exception.
**Fix** : Just I have removed the log. I did not write the output into the log file.
C:\Python25\python.exe GetValFromPYthonSCript.py
Now I am getting the output properly.
回答6:
SQL Server 2016 VS2015 Community 14.0.25431.01 U3 SSDT 14.0.61712.050
This one itched my brain for longer than I care to admit. I had two packages, each with a procedure returning a different sql statement that was assigned to a variable. One of the packages worked, and one of them did not.
In the working package/procedure, I had variable @sql
declared as varchar(max)
. Further in the query, I was adding a lookback date stored as a variable @dt
varchar(7)
. I was concatenating @dt
to @sql
.
In the non-working package/procedure, I had variable @sql
declared as varchar(max)
. Further in this query, I was adding a lookback date stored as a variable @dt varchar(max)
. In SSMS, this procedure works and returns the statement which is executable. In SSIS however, this does not work.
Once I changed the latter variable to a shorter char length (varchar(7))
, the task / variable assignment in VS succeeded.
Hope that helps.
来源:https://stackoverflow.com/questions/10437284/ssis-file-system-task-error-the-type-of-the-value-being-assigned-to-variable