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
301 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

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…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

789 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