?
Solved

SSIS - format date

Posted on 2014-04-08
6
Medium Priority
?
310 Views
Last Modified: 2016-02-10
Hi,

I am new to SSIS, I have SQL 2008 and VS 2008

I am trying to import an excel file into SQL, the datatype of the field is DATE, in the excel, the data looks like this

20140804
20130105
20091025

How can I convert it in SSIS during importing process?  thx
0
Comment
Question by:mcrmg
[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
  • 3
  • 2
6 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39985758
You should not have to.  It should be implicit.
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 39985777
>How can I convert it in SSIS during importing process?
I recommend against this.  If something throws an error during a combined import and conversion process, then it's more work for you to figure out what generated the error: the data being imported, or the SSIS conversion.

A more supportable approach would be to import it all as a varchar field into a staging table, then once it's imported successfully perform your conversions, to include a methodology to report a conversion failure, e.g. 20140231 not being a valid date.
0
 

Author Comment

by:mcrmg
ID: 39985880
Once I imported them into a staging table, would you recommend I do the conversions in SQL via query or do it in SSIS?

Also, assume there is only one field I need to convert, eg. from 20120522 to 5/22/2012.

What would you recommend to "correct" all the data type, as your post, initially would be all varchar most likely.  Should I create a new table with correct data type then import data from staging table to this table?  thx
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 66

Accepted Solution

by:
Jim Horn earned 1600 total points
ID: 39985913
>would you recommend I do the conversions in SQL via query or do it in SSIS?
Yes, but I'll admit that that's a style preference, so your mileage may vary.
It's easier in T-SQL, plus I can do fancy-schmancy things like incrememt a validation_errors (int) column if anything fails a validation, and add English-sounding messages to a validation_message (varchar(1000)) column, then those can be used as the basis of the 'what failed validation?' T-SQL and messanging.

>Also, assume there is only one field I need to convert
In that case, it would be easy enough to have just one table, with columns your_date varchar(100), and your_date_edited (date), and do the conversion as an UPDATE statement.
0
 

Author Comment

by:mcrmg
ID: 39985928
thank you very much
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 39985945
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

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…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

777 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