Dynamic Column Names in Flat File Destination

Hello,
Inside a Data Flow Task, I have an ADO.Net data source which executes a stored procedure that provides results in 5 columns.
The requirement is to have it connect to a flat file destination, such that the column names is dependent on what data was pulled by the data source. There is a variable indicator which identifies the data that was pulled. For example:
If the indicator is 0, then the columns names will be A,B,C,D,E. Otherwise, if the indicator is 1, then column names will be V,W,X,Y,Z.
Any suggestions will be of great help.
AJ

If you only have two variations then use a branched execution (based on precedence constraints) and direct it to one DFT or another based on the result returned by the stored procedure.
Otherwise use .net
code to create one package or another dynamically.
PS: I suggest not to bother using SSIS for such a simplistic scenario.
Arthur My Blog

Similar Messages

  • Dynamic Header Values in Flat File Destination

    Hi,
    I have to put 'T' or 'P' as part of a header in a flat file destination. The header is sourced via a work table which defines what the header looks like. One of the columns should contain 'T' for test or 'P' for production. When the package is executed in
    the test environment, 'T' should appear as part of the header. When the package is executed in the production environment, 'P' should appear as part of the header.
    Any ideas on how to achieve this is very much welcome.
    Thanks,
    AJ

    Package parameter indicating the environment and a DerivedColumn transform that generates a column with T or P depending on the parameter value.

  • Flat file destination error

    hi
    i am adding new field to my existing package which is char(10).
    getting this error:
    [Flat File Destination [139]] Error: Data conversion failed. The data conversion for column "MEMBER_ID" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
    i right click flat file destination->i only see external and input column over there,
    there is no output column.
    in flat file connection mamanger ->outputcolumn->its char(10)
    what needs to be change here?

    Hi coool_sweet,
    According to your description, you are trying to add a new source column to a flat file in an existing package.
    Based on the error message, the issue should be caused by text was truncated when load new column to column "Column1" in Flat File Destination. Because the length of new column data should be more than 10 (with some junk values) in the Source,
    while you are trying to convert the column to 10 as the character length.
    To fix this issue, we can increase the length of column "Column1" in Flat File Connection Manager. Alternatively, if you still want to convert the new column to a column with length 10, we can right-click the Source component to select “Show Advanced
    Editor”, then go to tab 'input and output properties' to expand the output column corresponds to the column "Column1", change TrancationRowDiposition property to RD_IgnoreFailure.
    Besides, the issue can also be caused by using some special characters in the new column. We can check the Unicode checkbox on the right hand side of Locale property in Flat File Connection Manager to fix this issue. For more details, please see the following
    thread:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/d3605656-4a13-47b6-b96e-45379e2b2a9f/export-to-flat-file-with-unicode-chinese-characters?forum=sqlintegrationservices
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • [Flat File Destination [220]] Error: Failed to write out column name for column "Column 2"

    I am using SSIS to extract fixed width data into a flat file destination and I keep getting below error. I have tried almost everything in this forum but still no solution. can anyone help me out to solve this problem.
    [Flat File Destination [220]] Error: Failed to write out column name for column "Column 2".
    [SSIS.Pipeline] Error: component "Flat File Destination" (220) failed the pre-execute phase and returned error code 0xC0202095
    Thanks

    Hi Giss68,
    Could you check the Advanced tab of the Flat File Connection Manager to see whether the InputColumnWidth and the OutputColumnWidth properties of the Column2 has the same value? Please refer to the following link about the same topic:
    http://stackoverflow.com/questions/10292091/how-do-i-fix-failed-to-write-error-while-exporting-data-to-ragged-right-flat-fil 
    If it doesn’t work, please post the sample data and the advanced settings of Column2 for further analysis.
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • Reorder columns in Flat File Destination

    Hi Friend's
    Although, I did some google in order to find the solution for reording the columns before exporting to a text file using FLAT FILE DESTINATION, one of the work around which i found is editing the final package xml file and moving the DTS:FlatFileColumn
    fields as required.
    Is there any other solution in order to avoid this approach as I have some 40 fields to be displayed in text file and manually reordring these fields in xml would be cumbersome.
    I need to create  text file using FLAT FILE DESTINATION.

    SSIS Data flow doesn't support dynamic metadata, and any changes in metadata like re-arrange mappings should be done manually. if you want to have columns in a re-arrange design which could be re-mapped dynamically and simply it is better to looks for
    another way than data flow task, dynamic t-sql queries can be good alternative.
    http://www.rad.pasfu.com
    My Submitted sessions at sqlbits.com

  • Flat File Destination Multiple Delimiters

    Hi Guys,
    This might been an easy one for you. I need to find out if the data from a table can be loaded into a text file with multiple delimiters or not using SSIS? For example, if I have 2 columns of data from a table,
    ID Name
    100 Mark
    I need to load this into a flat file and the output should be like this
    100,@Mark
    So basically, I need to have 2 delimiters in the flat file destination namely "," and "@". How can this be done.
    Thanks in advance.

    Can't you just fill in two delimiters in the Column Delimiter field of the Flat File Connection Manager (never tried it)?
    Alternatives:
    -In the source query add a @ to the second column: select column1,
    '@' + column2 as column2 from yourTable
    -Add a Derived Column with an expression that adds a @ in front of column2: "@" + [column2]
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • How to change recordset bahaviour to accept dynamic column names in the where clause

    Hi
    im using php-mysql and i make a recordset and i want to make the column names in the where clause to be dynamic like
    "select id,name from mytable where $tablename-$myvar";
    but when i do this my i break the recordset and it disappear
    and when i use variables from advanced recordset it only dynamic for the value of the column not for the column name
    and when i write the column name to dynamic as above by hand it truns a red exclamation mark on the server behaviour panel
    so i think the only way is to change the recordset behaviour is it? if so How to make it accept dynamic column names?
    thanks in advance.

    As bregent has already explained to you, customizing the recordset code will result in Dreamweaver no longer recognizing the server behavior. This isn't a problem, but it does mean that you need to lay out your dynamic text with the Bindings panel before making any changes. Once you have changed the recordset code, the Bindings panel will no longer recognize the recordset fields.
    Using a variable to choose a column name is quite simple, but you need to take some security measures to ensure that the value passed through the query string isn't attempting SQL injection. An effective way of doing this is to create an array of acceptable column names, and check that the value matches.
    // create array of acceptable values
    $valid = array('column_name1', 'column_name2', 'column_name3');
    // if the query string contains an acceptable column name, use it
    if (isset($_GET['colname']) && in_array($_GET['colname'], $valid)) {
      $col = $GET['colname'];
    } else {
      // set a default value if the submitted one was invalid
      $col = 'column_name1'
    You can then use $col directly in the SQL query.

  • Saving result from sp_executesql into a variable and using dynamic column name - getting error "Error converting data type varchar to numeric"

    Im getting an error when running a procedure that includes this code.
    I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql
    DECLARE @retval AS DECIMAL(12,2)
    DECLARE @MonthVal VARCHAR(20), @SpreadKeyVal INT
    DECLARE @sqlcmd AS NVARCHAR(150)
    DECLARE @paramdef NVARCHAR(150)
    SET @MonthVal = 'Month' + CAST(@MonthNumber AS VARCHAR(2) );
    SET @SpreadKeyVal = @SpreadKey; --CAST(@SpreadKey AS VARCHAR(10) );
    SET @sqlcmd = N' SELECT @retvalout = @MonthVal FROM dbo.CourseSpread WHERE CourseSpreadId = @SpreadKeyVal';
    SET @paramdef = N'@MonthVal VARCHAR(20), @SpreadKeyVal INT, @retvalout DECIMAL(12,2) OUTPUT'
    --default
    SET @retval = 0.0;
    EXECUTE sys.sp_executesql @sqlcmd,@paramdef, @MonthVal = 'Month4',@SpreadKeyVal = 1, @retvalout = @retval OUTPUT;
    SELECT @retval
    DECLARE @return_value DECIMAL(12,2)
    EXEC @return_value = [dbo].[GetSpreadValueByMonthNumber]
    @SpreadKey = 1,
    @MonthNumber = 4
    SELECT 'Return Value' = @return_value
    Msg 8114, Level 16, State 5, Line 1
    Error converting data type varchar to numeric.

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql <<
    This is so very, very wrong! A column is an attribute of an entity. The idea that you are so screwed up that you have no idea if you want
    the shoe size, the phone number or something else at run time of this entity. 
    In Software Engineering we have a principle called cohesion that says a model should do one and only one task, have one and only one entry point, and one and only one exit point. 
    Hey, on a scale from 1 to 10, what color is your favorite letter of the alphabet? Yes, your mindset is that level of sillyity and absurdity. 
    Do you know that SQL is a declarative language? This family of languages does not use local variables! 
    Now think about “month_val” and what it means. A month is a temporal unit of measurement, so this is as silly as saying “liter_val” in your code. Why did you use “sp_” on a procedure? It has special meaning in T-SQL.  
    Think about how silly this is: 
     SET @month_val = 'Month' + CAST(@month_nbr AS VARCHAR(2));
    We do not do display formatting in a query. This is a violation of at the tiered architecture principle. We have a presentation layer. But more than that, the INTERVAL temporal data type is a {year-month} and never just a month. This is fundamental. 
    We need to see the DDL so we can re-write this mess. Want to fix it or not?
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How can i get the column names in CSV file.

    Hi,
    After execution of infospoke i can not see the column names in that file.How can i get column of respective infoprovider?
    Thanks,
    Gananadha Lenka

    Hello Gana,
    Actually while exporting the data using Info Spoke, we have the possibility to modify the data that we send. This is possible using transformations.
    In your Info Spoke, you have a tab called Transformations.
    Here you need to create an implementation and then use BADi to populate data.
    Check if you can write a start routine sort of thing here and insert a new record into the internal table by hardcoding with your field headings.
    Let me know if you dont know how to create transformations.
    Kris...

  • Flat file Destination VS Raw file Destination ??

    Team ,
    Can some help me understand few differences and similarities  between Flat File Destination and Raw File Destination ? Thanks in advance .
    Rajkumar Yelugu

    Hi,
    Please check these differences :-
    Flat File Destination: The Flat File Destination component writes data out to a text file in one of the standard flat-file formats: delimited, fixed width, fixed width with row delimiter.
    Raw File Destination: The Raw File Destination is all about raw speed. It is an entirely native format and can be exported and imported more rapidly than any other connection type, in part because the data doesn’t need to pass through a connection
    manager.
    durgesh sharma

  • Header in flat file destination (ssis)

    Hi
    I am creating a header in the flat file destination which has some hard coded values and record count which will get its value from a variable assisgned to a row count transformation in the package.
    There is no problem in hard coded value but when i try to get the value of record count, i always get zero.
    This is how i am doing it.
    In the flat file destination, when we open flat file destination editor, i hard code the values which i want in the HEADER itself right there in the editor.
    For the record count, i go properties of the flat file and select expression. In the expression editor, in property, i am selecting 'HeaderRowDelimiter' and drag that variable in the expression box.
    Let me know if there is any suggestion.
    Thanks

    The value of the rowcount is only known AFTER the Data Flow Task is completely finished... and there header is writen before that.
    Here are some examples:
    http://agilebi.com/jwelch/2008/02/08/adding-headers-and-footers-to-flat-files/
    http://social.msdn.microsoft.com/Search/en-US/sqlserver?query=add%20header%20and%20footer%20ssis&rq=meta:Search.MSForums.ForumID(00e50af7-5f43-43ad-af05-d98b73c1f760)+site:microsoft.com&rn=SQL+Server+Integration+Services+Forum
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com

  • Dynamic column name sql?

    I need to do a select statement using dynamic column names. Can it be done WITHOUT building a string to execute the sql?
    In other words, I want to use a variable name in the SELECT part of a statement.
    Thanks

    Properly done, there shouldn't be a great difference in the performance of static and dynamic SQL. Of course, dynamic SQL is a whole lot more complicated to get right. It's also rather at odds with your requirement that column names get passed in dynamically-- if you don't know what columns you're going to select at compile time, you can't use static SQL.
    That said, there are a handful of tricks around using Oracle's built-in XML processing functionality to simulate dynamic SQL. This is almost certainly less efficient than doing dynamic SQL in your case, and a whole lot more complicated, but it's technically not dynamic SQL.
    The proper response, though, is almost certainly to either
    1) figure out how to design the application so that column names need not be passed in at runtime or
    2) use dynamic SQL.
    If at all possible, option 1 is generally preferable. While there are situations where dynamic SQL is necessary, those tend to be rather rare.
    Justin

  • Passing dynamic table name in ADO. net destination

    I am new to SSIS and I have a requirement where i need to pass dynamic table name in ADO .net destination .
    My package contains an "Execute Sql task" in the control flow which computes the destination table name to be provided at run time and stores it in a variable expression
    "@[User::Table_name]"(which has a scope of full package). 
    Now, the problem I'm facing right now is that , I am unable to use this variable expression in the ADO .Net Destination .
    I need to pass this variable expression as the table name in ado .net destination.
    But, whenever I use this variable in place as the table name I keep on getting this error and my package fails:- 
    [ADO NET Destination [403]] Error: The Table or View name is not expected. \n\t If you are quoting the table name, please use the prefix " and the suffix " of your selected data provider for quotation. \n\t If you are using multipart name,
    please use at most three parts for the table name. 
    Although ,I am able to run my package when i am providing the existing(static) table name.So there is nothing wrong with the  package.
    Tried a lot of things still not working..Please help...

    I am having the result stored in the variable expression . I just need a way to be able to use it as the Destination table in ADO .net Destination.
    I am not sure if this will work for you, but I am able to store the table name in variable and use it dynamically (via data flow task expression property ) as shown.
    Thanks, hsbal
    Hi Adeep,
    Based on my further research, just as hsbal said, we can set a variable as ADO.NET Destination table via Expressions property in Data Flow Task.
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Form with dynamic Column Names

    Hello,
    I am using "Form with report on table" and I would like to make use of dynamic column names labels that are derived from another table (sql). I am stuck on how to do this, any advice?

    Hi FourEyes;
    Try using this.
    Select Col1, Col2, Col3
    into :P1_Field1, :P1_Field2, :P1_Field3
    from Your_Table
    Where (your conditions);

  • Merge/Concat Multiple Columns in a Flat-File wthin ODI

    Hi,
    I was wondering if there is a quick way to merge/concat multiple columns in a Flat-File from within ODI, a functionality kinda similar to Essbase load rule files for join/split columns etc.
    Please let me know.
    Thanks

    Looks like the CONCAT function works only with Memory Engine. Could someone please confirm this? If this is true, I guess applying the patch is the only resolution.
    Thanks

Maybe you are looking for

  • Wrong Dutch translation in iTunes 8.0 (Windows XP/Vista)

    Hello there! I just noticed a small translation error in iTunes 8.0, it's about the free space available on an ipod/iphone. In English the grey bar at the bottom of the screen reads "Free", which is alright, but if you have your language set to Dutch

  • Remote app

    My Apple TV updated a couple nights ago.  Been trying to get the Remote App to work with it.   The app opens up, gives me the proper info to input on the Apple TV and then I get a music symbol on my Remote App where I paired it with Apple TV.    The

  • Cannot upgrade to snow leopard

    I have a late 2007 iMac (2GHz core 2 Duo). Since I purchased it, it has run Tiger, then Leopard flawlessly. I recently bought a Magic Trackpad which required me to upgrade to Snow Leopard. Unfortunately, 10.6 seems to kernel panic almost as soon as i

  • IPod buttons not working

    Hello! I purchased an iPod back in 2002, one of the original 20GB iPods w/ four buttons and a touch-wheel. It had been working wonderfully until late last year when the battery completely died. I had the battery replaced soon after and it had been wo

  • URGENT! (sorry for rudeness) - Error when trying to Expose Application as provider...

    User-Defined Exception (WWV-11230) User-Defined Exception (WWV-11230) The implementation package is not in a valid state. (WWC-43132) This is an application that contains four lov's, three reports and two forms, all of which inherit the apps privs.