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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Lessons learned during ten years of interviewing for SQL Server Integration Services (SSIS) and other Extract-Transform-Load (ETL) contract roles and two years of staff manager interviewing contractors.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

696 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