How do I set up a Derived Column Transformation to get row number in SSIS 2014? I am trying to import a ragged right flat file. I am wanting to import the file as one column and used Derive Column Transform to add a row number to each row. I would like to end up with a column called RowNum and a column called EntireRow. How do I do this?
A derived column won't be able to add a row number. Well, it can add a column called RowNum but the expression language doesn't support the ability to update a value on the fly. Instead, you'll need a Script Component. 

You can search for "SSIS generate surrogate key" and find plenty of reference implementations. I'm going to borrow from Joost's post Create a Row Id for this answer

// C# code: surrogate key script
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;

[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
    // New internal variable to store the rownumber
    private int rowCounter = 0;

    // Method that will be started for each record in you dataflow  
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        // Seed counter
        rowCounter++;

        // Fill the new column
        Row.RowNum = rowCounter;
    }
}


For those on 2005, the approach would look something like

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

&lt;Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute&gt; _
&lt;CLSCompliant(False)&gt; _
Public Class ScriptMain
    Inherits UserComponent

    ' New internal variable to store the rownumber
    Private rowCounter As Integer = 0

    ' Method that will be started for each record in you dataflow   
    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
        'Seed counter
        rowCounter = rowCounter + 1

        ' Fill the new column
        Row.RowNum = rowCounter
    End Sub
End Class


And since I love to provide Biml based answers so you can use the following code, also from Joost Creating BIML Script Component Transformation (rownumber) 

&lt;Biml xmlns="http://schemas.varigence.com/biml.xsd"&gt;
 &lt;Annotations&gt;
  &lt;Annotation&gt;
   File: Script Component Transformation RowNumber.biml
   Description: Example of using the Script Component as
   a transformation to add a rownumber to the destination.
   Note: Example has an OLE DB Destination that supports
   an identity column. Use your own Flat File, Excel or
   PDW destination that doesn't supports an identity.
   VS2012 BIDS Helper 1.6.6.0
   By Joost van Rossum http://microsoft-ssis.blogspot.com
  &lt;/Annotation&gt;
 &lt;/Annotations&gt;

 &lt;!--Package connection managers--&gt;
    &lt;Connections&gt;
            &lt;OleDbConnection
                Name="Source"
                ConnectionString="Data Source=.;Initial Catalog=ssisjoostS;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;"&gt;
            &lt;/OleDbConnection&gt;
            &lt;OleDbConnection
                Name="Destination"
                ConnectionString="Data Source=.;Initial Catalog=ssisjoostD;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;"&gt;
            &lt;/OleDbConnection&gt;
       &lt;/Connections&gt;

       &lt;ScriptProjects&gt;
             &lt;ScriptComponentProject ProjectCoreName="sc_c253bef215bf4d6b85dbe3919c35c167.csproj" Name="SCR - Rownumber"&gt;
                    &lt;AssemblyReferences&gt;
                           &lt;AssemblyReference AssemblyPath="Microsoft.SqlServer.DTSPipelineWrap" /&gt;
                           &lt;AssemblyReference AssemblyPath="Microsoft.SqlServer.DTSRuntimeWrap" /&gt;
                           &lt;AssemblyReference AssemblyPath="Microsoft.SqlServer.PipelineHost" /&gt;
                           &lt;AssemblyReference AssemblyPath="Microsoft.SqlServer.TxScript" /&gt;
                           &lt;AssemblyReference AssemblyPath="System.dll" /&gt;
                           &lt;AssemblyReference AssemblyPath="System.AddIn.dll" /&gt;
                           &lt;AssemblyReference AssemblyPath="System.Data.dll" /&gt;
                           &lt;AssemblyReference AssemblyPath="System.Xml.dll" /&gt;
                    &lt;/AssemblyReferences&gt;
                    &lt;ReadOnlyVariables&gt;
                           &lt;Variable VariableName="maxrownumber" Namespace="User" DataType="Int32"&gt;&lt;/Variable&gt;
                    &lt;/ReadOnlyVariables&gt;
                    &lt;Files&gt;
       &lt;!-- Left alignment of .Net script to get a neat layout in package--&gt;
                           &lt;File Path="AssemblyInfo.cs"&gt;
using System.Reflection;
using System.Runtime.CompilerServices;

//
// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("SC_977e21e288ea4faaaa4e6b2ad2cd125d")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("SSISJoost")]
[assembly: AssemblyProduct("SC_977e21e288ea4faaaa4e6b2ad2cd125d")]
[assembly: AssemblyCopyright("Copyright @ SSISJoost 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers 
// by using the '*' as shown below:

[assembly: AssemblyVersion("1.0.*")]
                           &lt;/File&gt;
       &lt;!-- Replaced greater/less than by &amp;gt; and &amp;lt; --&gt;
                           &lt;File Path="main.cs"&gt;#region Namespaces
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
#endregion

/// &amp;lt;summary&amp;gt;
/// Rownumber transformation to create an identity column
/// &amp;lt;/summary&amp;gt;
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
 int rownumber = 0;

 /// &amp;lt;summary&amp;gt;
 /// Get max rownumber from variable
 /// &amp;lt;/summary&amp;gt;
 public override void PreExecute()
 {
  rownumber = this.Variables.maxrownumber;
 }

 /// &amp;lt;summary&amp;gt;
 /// Increase rownumber and fill rownumber column
 /// &amp;lt;/summary&amp;gt;
 /// &amp;lt;param name="Row"&amp;gt;The row that is currently passing through the component&amp;lt;/param&amp;gt;
 public override void Input0_ProcessInputRow(Input0Buffer Row)
 {
  rownumber++;
  Row.rownumber = rownumber;
 }
}
                           &lt;/File&gt;
                    &lt;/Files&gt;
                    &lt;InputBuffer Name="Input0"&gt;
                           &lt;Columns&gt;
                           &lt;/Columns&gt;
                    &lt;/InputBuffer&gt;
                    &lt;OutputBuffers&gt;
                           &lt;OutputBuffer Name="Output0"&gt;
                                  &lt;Columns&gt;
                                        &lt;Column Name="rownumber" DataType="Int32"&gt;&lt;/Column&gt;
                                  &lt;/Columns&gt; 
                           &lt;/OutputBuffer&gt;
                    &lt;/OutputBuffers&gt;
             &lt;/ScriptComponentProject&gt;
       &lt;/ScriptProjects&gt;

       &lt;Packages&gt;
             &lt;!--A query to get all tables from a certain database and loop through that collection--&gt;
             &lt;# string sConn = @"Provider=SQLNCLI11.1;Server=.;Initial Catalog=ssisjoostS;Integrated Security=SSPI;";#&gt;
             &lt;# string sSQL  = "SELECT name as TableName FROM dbo.sysobjects where xtype = 'U' and category = 0 ORDER BY name";#&gt;
             &lt;# DataTable tblAllTables = ExternalDataAccess.GetDataTable(sConn,sSQL);#&gt;
             &lt;# foreach (DataRow row in tblAllTables.Rows) { #&gt;

             &lt;!--Create a package for each table and use the tablename in the packagename--&gt;
             &lt;Package ProtectionLevel="DontSaveSensitive" ConstraintMode="Parallel" AutoCreateConfigurationsType="None" Name="ssisjoost_&lt;#=row["TableName"]#&gt;"&gt; 
                    &lt;Variables&gt;
                           &lt;Variable Name="maxrownumber" DataType="Int32"&gt;0&lt;/Variable&gt;
                    &lt;/Variables&gt;

                    &lt;!--The tasks of my control flow: get max rownumber and a data flow task--&gt;
                    &lt;Tasks&gt;
                    &lt;!--Execute SQL Task to get max rownumber from destination--&gt;
                    &lt;ExecuteSQL
                           Name="SQL - Get max rownumber &lt;#=row["TableName"]#&gt;"
                           ConnectionName="Destination"
                           ResultSet="SingleRow"&gt;
                           &lt;DirectInput&gt;SELECT ISNULL(max([rownumber]),0) as maxrownumber FROM  &lt;#=row["TableName"]#&gt;&lt;/DirectInput&gt;
                           &lt;Results&gt; 
                           &lt;Result Name="0" VariableName="User.maxrownumber" /&gt; 
                           &lt;/Results&gt; 
                    &lt;/ExecuteSQL&gt;

                    &lt;!--Data Flow Task to fill the destination table--&gt;
                    &lt;Dataflow Name="DFT - Process &lt;#=row["TableName"]#&gt;"&gt;
                    &lt;!--Connect it to the preceding Execute SQL Task--&gt;
                    &lt;PrecedenceConstraints&gt;
                           &lt;Inputs&gt;
                                  &lt;Input OutputPathName="SQL - Get max rownumber &lt;#=row["TableName"]#&gt;.Output"&gt;&lt;/Input&gt;
                           &lt;/Inputs&gt;
                    &lt;/PrecedenceConstraints&gt;

                    &lt;Transformations&gt;
                    &lt;!--My source with dynamic, but ugly * which could be replace by some .NET/SQL code retrieving the columnnames--&gt;
                    &lt;OleDbSource Name="OLE_SRC - &lt;#=row["TableName"]#&gt;" ConnectionName="Source"&gt;
                           &lt;DirectInput&gt;SELECT * FROM &lt;#=row["TableName"]#&gt;&lt;/DirectInput&gt;
                    &lt;/OleDbSource&gt;

                    &lt;ScriptComponentTransformation Name="SCR - Rownumber"&gt;
                           &lt;ScriptComponentProjectReference ScriptComponentProjectName="SCR - Rownumber" /&gt;
                    &lt;/ScriptComponentTransformation&gt;

                    &lt;!--My destination with no column mapping because all source columns exist in destination table--&gt;                       
                    &lt;OleDbDestination Name="OLE_DST - &lt;#=row["TableName"]#&gt;" ConnectionName="Destination"&gt;
                           &lt;ExternalTableOutput Table="&lt;#=row["TableName"]#&gt;"&gt;&lt;/ExternalTableOutput&gt;
                    &lt;/OleDbDestination&gt;
                    &lt;/Transformations&gt;
                    &lt;/Dataflow&gt;
                    &lt;/Tasks&gt;
             &lt;/Package&gt;
             &lt;# } #&gt;
       &lt;/Packages&gt;
       &lt;/Biml&gt;

&lt;!--Includes/Imports for C#--&gt;
&lt;#@ template language="C#" hostspecific="true"#&gt;
&lt;#@ import namespace="System.Data"#&gt;
&lt;#@ import namespace="System.Data.SqlClient"#&gt;