I'm trying to load data from oracle to SQl server in Ssis 2008 R2. In between I'm using Data conversion transformation for converting - sql-server

I'm trying to load data from oracle to SQl server in Ssis 2008 R2. In between I'm using Data conversion transformation for converting an varchar2 data to DT_TEXT. Here I'm getting an error
Description: Data conversion failed while converting column "PROJECT_DESC" (1762) to column "Copy of PROJECT_DESC" (1638). The conversion returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.
the length of the particular record is around 948 and the maximum length allowed is around 2000.
Can someone please let me know what is going wrong here.

The width of the new field "Copy of PROJECT_DESC" defined in the Data Conversion is smaller than the source field "PROJECT_DESC" being read from Oracle. This is why it is warning of a truncation. Determine the length of the source varchar2 field in Oracle and then change the new field "Copy of PROJECT_DESC" to match in the Data Conversion.
Hope this helps.

Related

Exporting a VARCHAR(MAX) Field from SQL to Excel in SSIS

I'm creating a SSIS Package to export Data from a SQL Server Table into an Excel Sheet. My Table has one column of datatype VARCHAR(MAX). And this column can have data as big as 30,000 characters sometimes. So I used a Data Conversion block to convert that column's DataType from it's original datatype text stream [DT_TEXT] to Unicode text stream [DT_NTEXT]. But when I execute the Package, I get this error An error occurred while setting up a binding for the "MyColumnName" column. The binding status was "DT_NTEXT".
I googled a lot but I couldn't get an answer to my problem. I'd appreciate all the help that I could get.
You can skip the data conversion task and just force the type when you extract from SQL Server SELECT CAST(MyBigColumn AS nvarchar(max)) As MyBigColumnUnicode but you're going to run into the problem that a cell in Excel cannot hold 100k characters.
Total number of characters that a cell can contain: 32,776
Excel specifications and limits

SSIS importing extra decimal values in to destination sql table from excel

I am trying to import "Financial data" from Excel files in to sql table. Problem I am facing is that My ssis package is incrementing decimal values. e.g -(175.20) from Excel is being loaded as "-175.20000000000005" in SQL.
I am using nVArChar (20) in destination SQL table. Images attached. What's the best data type in destination table. I have done a lot of reading and people seem to suggest decimal data but Package throws error for Decimal data type.Need help please.
Ended up changing the Data type to "Currency" in my SQL destination. Then added a data conversion task to change "DT_R8" data type from excel source to "currency[DT_CY]. This resolved the issue. could have used decimal or Numeric (16,2)data type in my destination as well but then i just went ahead with currency and it worked.
You could use a Derived Column Transformation in your Data Flow Task, with an expression like ROUND([GM],2) (you might need to replace GM with whatever your actual column name is).
You can then go to the Advanced Editor of the Derived Column Transformation and set the data type to decimal with a Scale of 2 on the 'Input and Output Properties' tab (look under 'Derived Column Output').
You'll then be able to use a decimal data type in your SQL Server table.

SQL Server 2014 SSIS Excel Source Task import to table date and text to numeric conversion issues

Using SQL Server 2014 SSIS to import an vendor supplied Excel file through the Excel Source Data Flow. Two issues I'm having related to data conversion to the SQL table.
In the file is a text column that has prices (numeric values) in it I can't not get it to transform into a numeric field (decimal(8,2)) in SQL. I have used the Data Conversion data flow task converting it to DT_NUMERIC and it fails to process the field. I have also tried to let it go through the Data Conversion task and converted through a Derived Column casting the field to Numeric. Both fail, I'm at a loss as to how to get this into the database in a Decimal/Numeric format.
In the same file are three date fields with dates that look like 07/18/2015 in Excel. I have tried similarly with the Data Conversion and Derived column to get the date into the database as SQL date formats. I have cast the dates at DT_DBDATE and DT_DBDATE and DT_DBTIMESTANP and neither has worked I have also tried taking the month day and year and rearranging them into the SQL date format with Substring/left/right functions to split the string. Also to no avail.
Here is what I tried:
Excel Source ---> Data Conversion ----> Derived Column -----> OLE DB Destination
In the excel source it recognized the date as text, I leave that be in the data conversion to deal with it in the Derived Column where I have tried.
a. (DT_DBDATE)("20" + RIGHT(TRIM(sale_start),2) + "-" + LEFT(TRIM(sale_start),2) + "-" + SUBSTRING(TRIM(sale_start),4,2)) - I have done this with and without the trim with same results. I have also used Right(sale_start,4).
b. (DT_DBDATE) sale_start
The SQL table is data type DATE. I have also changed it to DATETIME and used DT_DBTIMESTAMP in place of DT_DBDATE above.
I can't change the file I'm receiving it needs to process into the database the way it comes from the vendor. Looking at the data in excel there seems to be no reason it wouldn't be ok.
Any direction on bringing this data in would be much appreciated.
2.
I was able to figure this out although I don't completely understand what the connection setting is doing. Similarly with a XML file this connection setting wasn't necessary although some version of a derived column was, I the above I believe in my XML import.
For the EXCEL Solution:
1) In the Excel File connection I added IMEX=1 to the end of the connection under properties. So the connection string looked like this:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\SSIS\Test.xls;Extended Properties="EXCEL 8.0;HDR=YES;IMEX=1";
2) Used the following script in the derived column:
ISNULL([Copy of expected_date]) ? NULL(DT_DATE) : (LEN(TRIM([Copy of expected_date])) == 0 ? NULL(DT_DATE) : (DT_DATE)((DT_DBDATE)TRIM([Copy of expected_date])))
Thanks for taking the time to respond.

SSIS: XML to Excel export, truncation may happen due to inserting data from data flow column with a length of 4000 to database column with length 255

I'm using SQL 2008 R2 & Excel of format xlsx. I'm trying to export data to Excel through XML source.Everything is working fine, than for columns where data is more than 255 characters. I get a warning:
truncation may happen due to inserting data from data flow column with
a length of 4000 to database column with length 255
I've tried changing registry and IMEX value as per the blog. This doesn't seem to help me. Also, for me connection string (Excel Connection Manager) is
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Extract_8202014.xlsx;Extended
Properties="EXCEL 12.0 XML;HDR=YES";
As per MDSN for memo type columns we should define datatype as longtext if table is getting created at run time. I've done same. But it's not helping.

Importing CSV to SQL Server with text column > 8000 characters

I'm trying to import a csv file with two columns (sku, description) into SQL Server 2008 using the SQL Server management studio 2012 import/export wizard. Because the description column definitely has rows greater than 8000 characters, I go to the advanced tab when choosing the csv data source and click on the description column and click "Suggest Types". It then puts in 16718 for the OutPutColumnWidth property. Apparently there is a description in there somewhere that is THAT long.
The sql it generates is:
CREATE TABLE [dbo].[mag-prod-descriptions1] (
[sku] varchar(7),
[descrip] varchar(16718)
)
However, when I execute the import, I get the error "Could not connect source component. Error 0xc0204016: SSIS.Pipeline: The "Source - mag-prod-descriptions1_csv.Outputs[Flat File Source Output].Columns[Column 1]" has a length that is not valid. The length must be between 0 and 8000."
If I change the OutputColumnWidth property to 8000 then I get an error saying the column was truncated. I can't win.
How do I get the thing to allow me to import cells that are greater than 8000 characters?
Ack. Finally got it. The answer was to use the Text Stream datatype for the large column on the source file.
I see import issues with column size errors, I'm thinking...could this be a Unicode issue? Try using nvarchar instead of varchar when creating your table.
Reference: Unicode Works Better With SSIS

Resources