Cannot change external column length - ssis

I have an SSIS package with a Data Flow that populates an Excel Destination from OLE DB Source. One of the columns in the DB has 500 characters length. On running the package, I get a warning:
Warning: 0x802092A7 at Data Flow Task, Excel Destination [38]: Truncation may occur due to inserting data from data flow column "DT_WSTR_Description" with a length of 500 to database column "F6" with a length of 255.
I see that F6 external column does have length of 255. When I change it to 500, it becomes 255 again. How can I solve it?

On the Properties window for the Excel Destination, set ValidateExternalMetadata to false. Then right-click on the Excel Destination, select Show Advanced Editor and go to the Input and Output Properties pane. Expand the Excel Destination Input node and then do the same for the External Columns folder. Go to the F6 column and under Common Properties you can change the length of the column now without it reverting back.

Related

stuck with data conversion SSIS

I'm stuck with a conversion problem...or atleast at datatype problem.
Trying to read a csv-file and update a SQL-database with its content.
The column I have problems with have numbers like 64,51 (at most 3 digits with 2 decimals).
In the database I have set the datatype as decimal(3,2) and in the flat file Connection manager I have set it as decimal(DT_DECIAL) with the scale of 2.
Along the flow I do a Derived column, merging two columns into one and then convert the new column.
Looking in the advanced editor of the OLE DB-destination I can see that in the Input Columns the column is set as DT_DECIMAL, but in the External column its set as a DT_NUMERIC.
How do I change that?
I can change the properties but every time it reverts back to numeric when I press OK.
The errormessage says: "Conversion failed because the data value overflowed the specified type."
Thanks for all tips on this!

SSIS data load truncates values into destination table

I have an SSIS package with a simple Source(vertica query) and Destination (sql DB). When I load the data my data values are cut off.
For example, I have a Country code and this is listed as "C" instead of "CN" . I tried to put a DATA CONVERSION and change the data type to DT_STRING, which normally works, but this time it doesn't seem to do anything. Any idea on how I can handle these truncation's. I have mapped the field lengths all the same from source to destination.
Go into the Advanced Properties of the Source component, and go into each of the Output Columns that has truncated data, and set the Length property of each of those columns to the maximum possible length that the data in that column can be.
Also take out your data conversion component, since you shouldn't need it and it might interfere with the results of the above change.

SSIS 2012 column header is too long for column width Extracting fixed width flat file

I am attempting to extract a table from sql database into a fixed width flat file.
The file should have a column header
I am attempting to recreate a file that already existed where the header for certain columns(for example Gender with a width of 1) has a column name that is too long for it's column format.
The existing file just cuts off these column headers, so Gender(the db column name and input column to the destination becomes 'G' - just what will fit.. but when I attempt to reproduce the extract in SSIS 2012 by pointing at the existing file while creating the flatFile connectionManager It works without a header, but not when I check "column header in first data row"
Is there a way to change/shorten the column names to just what will fit in the format? I am using "ragged right" file format and the data looks perfect without column headers.
Any help is appreciated.
Steve
SSIS really likes consistent metadata. The flat file definition specifies that gender is a length of one and it's going to hold the column header to the same standard that it holds the data. My experience with fixed width files is that they've never had headers, which is painful when they're a few thousand bytes wide, which is likely due to the this problem.
What you can do is to manually specify a header row in the Flat File Destination.
Within my Connection Manager, I uncheck the Column Names in First Row and increment the Header Rows to Skip value to 1.
In my example, I used the following query
SELECT
*
FROM
(
VALUES
('AAAAAAAAAAAAAAAAAA','BBBBBBBBBBBBBBBBBBBBBBBB','M','CCCCCCC')
)D(c1, c2, Gender, c4);
This results in an output file that looks like
Col1Is18BytesWide NextColumnAlignsWithNextGenderSeeWhatIDidThere
AAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBMCCCCCCC
That may or may not be the solution you're looking for. I think it'd drive me mad seeing column headers not aligning with the data values but you never know how other systems expect their data.

SSIS package - Conditional distribution of record set in control flow

I have been working on a requirement which serves the following:
Fetching record set from an OLEDB source through an execute SQL task.
These record set is then formatted into fixed width and merged into a single column with the help of another Execute SQL task.
The formatted data is then exported to a flat file..
Now, the requirement has been changed to have the record set (Originally coming from OLEDB source) exported to three separate flat files (Each with different set of data) depending upon value of a package variable.
e.g If (USER::Instructor = 'DEV') then 5 fields will be extracted to one flat file.
e.g If (USER::Instructor = 'Jerry') then 7 fields will be extracted to another flat file. And so on..
My current challenge is I have to extract different set of data without using expressions in the precedence constraint.
You will need a different data flow task for file formats that you want to be able to export. So a different task for the 5 field export to the 7 field export.
In the Control Flow, you can choose which of these data flow tasks gets executed based on the value of your package variable.
For example, if you set the Disabled property of the 5 field data flow task to the expression #[USER::Instructor] != 'DEV' , then it would be disabled whenever the instructor was not Dev, and enabled whenever it was dev.

Have SSIS detect the column sizes of a csv file

I'm trying to import a csv file into SQL using SSIS and am hitting a fundamental flaw.
SSIS seems to determine that all fields are varchar(50), even though it correctly identifies the comma delimiter.
This is causing issues when I try to send the data to my table in SQL.
Is there a way of making it recognise that a field of length 3 is actually a field of length 3, and not 50?
Thanks
Yes, there's a Suggest Types function in the Flat File Connection Manager Editor.
Assume you have got a CSV file shown in the first image.
Create a new Flat file connection, and browse this file on your computer. The Columns tab shows the sample of the file.
Click Advanced tab. There you can see all columns have DT_STR type with the length of 50. What you can see is the Suggest Types... button. Click this.
Set parameters as you like. Defaults are all right in my case. Click OK.
Now the first column has the type of DT_STR with the length of 1. (The other two columns have got new types as well. The Number column got DT_I1 (because we choosed the smallest appropriate integer type option), and the Date column got DT_DATE.