Solved

I am importing a .csv file comma delimited to sql2008r2 and 2 of the columns are datebase timestamp.  Some of the rows contain the value NULL .

Posted on 2014-10-24
2
304 Views
Last Modified: 2016-02-11
I am importing a .csv file comma delimited to sql2008r2 and 2 of the columns are datebase timestamp.  Some of the rows contain the value NULL and I receive the following error: "Error Data  conversion failed.  The data conversion for column "START_DTE" returned status value 2 and status text"  The value could not be converted because of a potential loss of data".

Copy of the .csv record and the 2 NULLs before the datetime fields are START_DTE and END_DTE and in the table these are also database timestamp:

98-017 (Use),All of the warehouse,NULL,NULL,NULL,2014-08-14 00:00:00.000

I have saved this to SSIS and included a screen shot.
Doc2.docx
0
Comment
Question by:wdbates
2 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 40402775
Two ways to resolve this:

1.

(My preferred) Contact the source of this .csv file, and after a good smacking tell them to remove the NULL values from the file, and replace them with an empty string, e.g. ,2014-01-01, changes to ,,

2.

If the above is not possible, in your SSIS package change the destination to be a staging table (I prefix these with ssis_ or timp_) that is all varchar values, and pump the file data into it.  Then run T-SQL to remove the NULLs, and do other data validation checks such as dates are dates, numbers are numbers, etc.  Then do an INSERT to move that data into your final destination table.

Also a good idea to gracefully handle any rows that fail these validation checks.
0
 

Author Closing Comment

by:wdbates
ID: 40402837
Thanks Jim.  

That did the trick!
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In couple weeks ago, I encountered an extremely difficult problem while deploying 2008 SSIS packages to a new environment (SQL Server 2014 standard).  My scenario is: We have one C# application that is calling 2008R2 SSIS packages to load text fi…
A couple of weeks ago, my client requested me to implement a SSIS package that allows them to download their files from a FTP server and archives them. Microsoft SSIS is the powerful tool which allows us to proceed multiple files at same time even w…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question