Solved

SSIS - format date

Posted on 2014-04-08
6
297 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
  • 3
  • 2
6 Comments
 
LVL 75

Expert Comment

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

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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 65

Accepted Solution

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

Expert Comment

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

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
My client sends data in an Excel file to me to load them into Staging database. The file contains many sheets that they have same structure. In this article, I would like to share the simple way to load data of multiple sheets by using SSIS.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

896 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now