As I explained earlier about Foreach Loop Container. One of regular reader of blog send me an email about one issue. Let me share that problem with all readers. With this example, Foreach Loop Container, What to do if we want to save file name along with each row, so we can come to know that which row is from which file ? This is very practical problem that we need to fix. To solve this, I come up with following solution. 1. I used "Derived Column", one of Data Flow Transformations in Data Flow Operations. 2. Configure Derived Column: As we have variable, FileName, as defined in, SQL SERVER: SSIS - Foreach Loop Container. Here I used that variable as a new column. By dragging that User variable to Expression. By default it assign UNICODE STRING DataType to this new column. We need to change it by: A. Right click on "Derived Column", Go to Show Advanced Editor B. Set DataType to String as: 3. That's it. Now just add it to Destination Column Mapping with your Database column. Let me know your suggestions. |
Learn SQL and database management at SQLYoga for articles, tutorials, and tips to improve your skills and streamline data operations. Join our community!
January 10, 2010
SQL SERVER: SSIS - Derived Column Data Flow Transformation
Labels:
Data Transformation,
Derived Column,
For Each Loop Container,
SQL,
SQL Server 2005,
SSIS,
SSIS Task,
Tejas Shah
18+ years of Hands-on Experience
MICROSOFT CERTIFIED PROFESSIONAL (Microsoft SQL Server)
Proficient in .NET C#
Hands on working experience on MS SQL, DBA, Performance Tuning, Power BI, SSIS, and SSRS
Subscribe to:
Post Comments (Atom)
You could also use the FileNameColumnName property of the Flat File Source Adapter to get the name of teh file. Saves all that messing about with variables.
ReplyDeleteRead more: http://msdn.microsoft.com/en-us/library/ms135923.aspx#flatfile
Regards
Jamie
Nice article, thank you jamiet for the info on FileNameColumnName property
ReplyDeletePlease how do create the variable, what is the value ?
ReplyDeletehow do you configure the variable(Filename) and what is the value in the Value column
ReplyDeleteHi Thomas,
ReplyDeletePlease review my another post: http://sqlyoga.com/2010/04/sql-server-ssis-get-file-name-with-flat.html. Here, I have explained how to get FileName while processing multiple files and assign it to the row.
Hope this helps you. Let me know if there is any question.
Thanks,
Tejas
thanks to Jamiet for the brilliant contribution for using the FileNameColumnName property of the Flat File Source Adapter to get the name of file names.
ReplyDeleteThanks