Formula-Puzzle together your xml
The other answers are right in saying that you can take the xml of the package.
I once did this for 100+ columns when I had to make a mapping for the lookup or derived column component:
- I took the xml of the dtsx,
- made the needed default column types as defaults in MS Excel and then
- mapped the SQL column list of data types of the CREATE statement with its SSIS data types,
- built all of the needed default xml patterns from mere tests in a dummy project,
- of course with the column names as placeholders so that they would be replaced or concatenated into those default xml blocks.
On the whole, I puzzled together the needed xml by handycraft. This worked and saved me not just a lot of time, but also mistakes and foremost, nerves, and this sort of mapping platform helped me again and again.
I can assure you that a calculation sheet is already enough to do the full mapping if you know how to concatenate strings and lookups with more than one search word.
Other ways
You might do the same thing in another programming language, not just in calculation sheet formulas, one keyword might be BIML, but see all of the hints at How to Map Input and Output Columns dynamically in SSIS?.
PS: unchanged ReadOnly columns are passed by default
This is just a small remark for those who are new to the script component as such.
In the question above, the columns need an output column since they are cleaned or changed in some way. Do not think that you have to make an output column for each input column. If you do not change anything, you can just pass all of the input columns to the output arrow without any new output columns in the main menu. The columns stay as they are in the downstream, always available with this name, there is no need to choose them as the output columns of the script component to keep them alive in the downstream of the flow. See also is it possible to pass columns through an SSIS script transformation?.
If you still try to add an output column for each input column and give it the same name, you will see the error:
Script Component [153]]: Column name "my_column1" in output "Output 0" cannot be used because it conflicts with a column of the same name on synchronous input "Input 0".
PSS: List of SSIS data types
For a full mapping of everything, I found this list in the SetObject() function of the BufferWrapper class that is called by the Input0Buffer class in C#:
public void SetObject(int columnIndex, object value, bool failSilently = true)
{
BufferColumn columnInfo = GetColumnInfo(columnIndex);
try
{
switch (columnInfo.DataType)
{
case DataType.DT_BOOL:
case DataType.DT_BYREF_BOOL:
SetBoolean(columnIndex, (bool)value);
break;
case DataType.DT_I2:
case DataType.DT_BYREF_I2:
SetInt16(columnIndex, (short)value);
break;
case DataType.DT_I4:
case DataType.DT_BYREF_I4:
SetInt32(columnIndex, (int)value);
break;
case DataType.DT_R4:
case DataType.DT_BYREF_R4:
SetSingle(columnIndex, (float)value);
break;
case DataType.DT_R8:
case DataType.DT_BYREF_R8:
SetDouble(columnIndex, (double)value);
break;
case DataType.DT_CY:
case DataType.DT_BYREF_CY:
case DataType.DT_DECIMAL:
case DataType.DT_NUMERIC:
case DataType.DT_BYREF_DECIMAL:
case DataType.DT_BYREF_NUMERIC:
SetDecimal(columnIndex, (decimal)value);
break;
case DataType.DT_I1:
case DataType.DT_BYREF_I1:
SetSByte(columnIndex, (sbyte)value);
break;
case DataType.DT_UI1:
case DataType.DT_BYREF_UI1:
SetByte(columnIndex, (byte)value);
break;
case DataType.DT_UI2:
case DataType.DT_BYREF_UI2:
SetUInt16(columnIndex, (ushort)value);
break;
case DataType.DT_UI4:
case DataType.DT_BYREF_UI4:
SetUInt32(columnIndex, (uint)value);
break;
case DataType.DT_I8:
case DataType.DT_BYREF_I8:
SetInt64(columnIndex, (long)value);
break;
case DataType.DT_UI8:
case DataType.DT_BYREF_UI8:
SetUInt64(columnIndex, (ulong)value);
break;
case DataType.DT_DBDATE:
case DataType.DT_BYREF_DBDATE:
SetDate(columnIndex, (DateTime)value);
break;
case DataType.DT_DATE:
case DataType.DT_BYREF_DATE:
case DataType.DT_FILETIME:
case DataType.DT_BYREF_FILETIME:
case DataType.DT_DBTIME:
case DataType.DT_BYREF_DBTIME:
case DataType.DT_DBTIMESTAMP:
case DataType.DT_BYREF_DBTIMESTAMP:
case DataType.DT_DBTIME2:
case DataType.DT_BYREF_DBTIME2:
case DataType.DT_DBTIMESTAMPOFFSET:
case DataType.DT_BYREF_DBTIMESTAMPOFFSET:
case DataType.DT_DBTIMESTAMP2:
case DataType.DT_BYREF_DBTIMESTAMP2:
SetDateTime(columnIndex, (DateTime)value);
break;
default:
throw new Exception(columnInfo.DataType.ToString() + " not yet supported ");
}
}
catch (Exception e)
{
if (failSilently == false)
throw e;
else
try { SetNull(columnIndex); } catch { }
}
}