?
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
Medium Priority
?
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
I have a large data set and a SSIS package. How can I load this file in multi threading?
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

770 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