Solved

Importing Date information from Exel into SQL Server 2008 Table

Posted on 2010-11-22
6
391 Views
Last Modified: 2012-05-10
I have a table with a definition like this:
CREATE TABLE [dbo].[SPECIAL_DAYS](
      [start_date] [date] NULL,
      [end_date] [date] NULL
) ON [PRIMARY]

I want to populate this table with data from an excel spreadsheet.   I know how to use the SQL Server import and export wizard.  My problem is with data type conversions.  I have tried formatting the spreadsheet as text and as date, but there is always a conversion error and no data gets loaded.    I'm using Excel 2007, and I'd like to do this using the import and export wizard.  How?
0
Comment
Question by:cipriano555
[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
6 Comments
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 34187473
How many records?  What is the error?
0
 
LVL 6

Expert Comment

by:subhashpunia
ID: 34187809
Try first importing the data in a varchar column as text data. Then add another column in table and update with right conversion functions.
Pls show the data as in excel file and the expected format.
0
 
LVL 18

Expert Comment

by:x-men
ID: 34189808
try "set dateformat" on the SQL server, according to the format on the Excel Sheet
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:cipriano555
ID: 34189834
subhashpunia.

From your comment you seem to be saying, SQL server import wizard doesn't understand Excel formatting, at least not in this instance.  I would have thought if you formatted your data in Excel as a DATE, the import wizard would say, "oh, this is a date value, it's going into a date field" and do the obvious.  But it doesn't, it converts the date to an integer and then throws a conversion error.

I'm trying to make something easy for a user to input a fairly modest set of time frames, If I have to read it in as a varchar then convert, no problem, but I thought there would be a way to accomplish this directly without doing a conversion as you have described.

John

0
 
LVL 6

Accepted Solution

by:
subhashpunia earned 500 total points
ID: 34195549
Yes, Import wizard at least can directly import data in a Date type column. But I here suggested to import data in varchar type columns because sometime due to formatting in excel (some extra character added automatically) do not convert into date type. But after importing in SQL server we have full visibility on data and we can convert as needed.
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 34198686
User inputted data is the hardest thing to import because of human error and personal preference.  You don't know if 11/10/2010 is Nov-10 or Oct-11.  Or at least SQL Server doesn't always.  I would recommend, if you are having them input data into Excel, to do the validation into a known format in Excel so that SQL Server doesn't have any issues.  

The most important thing is for the data to be consistent.  Meaning you can't have 12/31/2010 and 31/12/2010 the same column.  Both are valid dates to SQL Server but it can't choose.

0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
point in time restore in SQL server 26 54
SQL Select Query help 1 50
T-SQL: I need to add an index on a field 5 50
Please explain Equi-join 3 44
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.
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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