Flat file csv import to SQL Server 2005 DB
Hi, I have a csv file in the following format: Sl, date,Variation 1,"September 2, 2012",1.310308688% 15,"August 19, 2012",2.746544587% 22,"August 12, 2012",3.818126145% I am using a ssis task to import the csv to a table whose structure is : CREATE TABLE [dbo].[AlertTestTbl]( [SlNo] [int] IDENTITY(1,1) NOT NULL, [date] [varchar](50) NULL, [Sl] [varchar](50) NULL, [Percentage] [decimal](10, 2) NULL, [Date] [datetime] NULL CONSTRAINT [DF_AlertTestTbl_CurDate] DEFAULT (getdate()) ) ON [PRIMARY] I am getting the following errors on running the data flow. [OLE DB Destination [913]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Invalid character value for cast specification". [OLE DB Destination [913]] Error: There was an error with input column "% Difference in queries" (954) on input "OLE DB Destination Input" (926). The column status returned was: "The value could not be converted because of a potential loss of data.". [OLE DB Destination [913]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "input "OLE DB Destination Input" (926)" failed because error code 0xC0209077 occurred, and the error row disposition on "input "OLE DB Destination Input" (926)" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure. [DTS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "OLE DB Destination" (913) failed with error code 0xC0209029. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure. [DTS.Pipeline] Error: SSIS Error Code DTS_E_THREADFAILED. Thread "WorkThread0" has exited with error code 0xC0209029. There may be error messages posted before this with more information on why the thread has exited. Please help with a good solution Thanks
September 4th, 2012 10:17am

Hi, What is the datatype of the input column "% Difference in queries"? Do you do a data conversion of that column so that it fits into decimal datatype in the destination column([Percentage])? I think you need it.Rajkumar
Free Windows Admin Tool Kit Click here and download it now
September 4th, 2012 10:32am

I see a couple of things that may cause some issues... [decimal](10, 2) does not cast to 1.310308688% Your declaration indicates 10 places total with 2 decimals to the right of the decimal point. I am also not sure you want to include the % character in the raw data. From BOL decimal[ (p[ ,s] )] and numeric[ (p[ ,s] )] p (precision) The maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision of 38. The default precision is 18. s (scale) The maximum number of decimal digits that can be stored to the right of the decimal point. Scale must be a value from 0 through p. Scale can be specified only if precision is specified. The default scale is 0; therefore, 0 <= s <= p. Maximum storage sizes vary, based on the precision. Secondly [varchar](50) - may or nay not be an issue, Excel and .csv if I remember correctly create nvarchar data that SSIS will require an explicit conversion. Lastly I would make sure the fields are mapped correctly. Timothy Vanover
September 4th, 2012 10:45am

[decimal](10, 2). I am trying to directly import the csv to the table which structure is available above
Free Windows Admin Tool Kit Click here and download it now
September 5th, 2012 3:03am

The column has been changed to decimal(10, 10).Also the other fields have been changed to nvarchar. Still it is not importing
September 5th, 2012 3:07am

May want to define your table with distinct names - Date and date are not unique column names CREATE TABLE [dbo].[AlertTestTbl]( [SlNo] [int] IDENTITY(1,1) NOT NULL, [date] [varchar](50) NULL, [Sl] [varchar](50) NULL, [Percentage] [decimal](12, 10)NULL,--this should be (12,10) if 9-10 are required to the right as percentages can be 2 digits to the left [Date] [datetime] NULL CONSTRAINT [DF_AlertTestTbl_CurDate] DEFAULT (getdate()) ) ON [PRIMARY] Your File is also going to split in the date as a .csv -Comma Delimited file as you have a comma in the date You may want to have the file made with a format like this: Sl, date,Variation 1,2-Sep-12,1.310308688 15,19-Aug-12,2.746544587 22,12-Aug-12,3.818126145 If using the wizard make sure to set the size of the Percentage column as it will default to 50 and needs to be the correct of 12 I got it to import easily with these steps...Hope this is helpful... Timothy Vanover
Free Windows Admin Tool Kit Click here and download it now
September 5th, 2012 7:32am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics