Solved

Importing Date information from Exel into SQL Server 2008 Table

Posted on 2010-11-22
6
393 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
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 we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
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…

628 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