1

I want to be able to send emails using SSIS. I followed the instructions at "How to send the records from a table in an e-mail body using SSIS package?". However, I am getting an error:

Error: ForEach Variable Mapping number 1 to variable "User::XY" cannot be applied

while running the package. My source table has 5 columns (bigint, datetime, nvarchar, nvarchar, nvarchar types).

Another error is:

Error: The type of the value being assigned to variable "User::XY" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.

What could the problem be?


UPDATE: As I was trying to find out the problem, I have done this: while taking the data from Execute SQL Task, I cast the int data to varchar and then use the variable with String data type and it works. But how should I set the variable so it has INT data type, not varchar?

Community
  • 1
  • 1
DNac
  • 2,663
  • 8
  • 31
  • 54
  • It seems I need to set that variable as Int instead of string. So I did change the DataType to "Int32" but thats probably wrong way. – DNac Mar 24 '14 at 13:45

1 Answers1

1

I just ran into this problem & resolved it, although I don't know exactly how.

Running SSIS for SQL Server 2008 R2: a) query pulls rows into an object b) for each trying to loop through and pull values for the first two columns into variables (this had already been running fine--I had come back to edit the query and the for each loop and add an additional variable for branching logic) c) error mapping variable '1', which happened to be an int and happened to have the same name as the column I was pulling from.

I tried deleting the variable-to-column reference in the foreach loop and re-adding it, and I discovered that the variable was not listed anymore in the list of variables allowed for mapping.
I deleted the variables, created a new variable of the same type (int32) and name, added it, and things ran fine.

george
  • 101
  • 6