Geekzone: technology news, blogs, forums
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.

264 posts

Ultimate Geek
Inactive user

#36907 3-Jul-2009 10:18
Send private message

Hi Peoples,

I'm attempting to import a csv file into a databse table using a stored procedure, but I'm running into a little issue with one of the date fields. The column is in smalldatetime format, and the value of the field that the bulk insert is failing on is "01/06/2008", on the first row of the csv. The error I am getting is a type mis-match error. This is the 10th column in the db so i know its inserting the rest of the data properly.

Any help anyone can give would be much appreciated.

Create new topic
BDFL - Memuneh
67075 posts

Uber Geek

Lifetime subscriber

264 posts

Ultimate Geek
Inactive user

  #230617 3-Jul-2009 10:42
Send private message

I just tried changing the value in the cvs of the first row and I'm still getting the same error.


264 posts

Ultimate Geek
Inactive user

  #230625 3-Jul-2009 11:04
Send private message

I just tried changing the format to 20080601 as well with no luck. I did however manage to use DTS to import that data. Does anyone know of a way I can create a stored procedure from this? Or should I just make it a scheduled task? The data will need to be updated every few weeks but I would rather have it as a stored procedure so I can interact with it through the website rather than having to remote console in all the time.

264 posts

Ultimate Geek
Inactive user

  #230630 3-Jul-2009 11:24
Send private message

Just realised that the data is being imported all as a varchar which is not what I want, and I really wanna try and get the sp working. The sp I am using is

CREATE PROCEDURE dbo.sp_ImportData




FROM 'c:\Data.csv'



I realise I probably have to convert the data from a varchar to smalldatetime or something similar, just not sure how. (You'll have to forgive me, I'm really really new to all this database stuff).

Thanks for any suggestions or help.

264 posts

Ultimate Geek
Inactive user

  #230671 3-Jul-2009 13:25
Send private message

Well I have just figured out what the problem was. When I was opening the file the default was for it to open in Excel, which is fine, except that excel displays the information slightly differently to how it appears in the csv. In the csv everything that is not a number is surrounded by " ", with numbers having nothing surrounding them. In excel everything was displayed without quotes. The solution is to create a File Format to import the data into the table.

Hopefully this helps save someone else from this mistake later on.

Create new topic

Twitter and LinkedIn »

Follow us to receive Twitter updates when new discussions are posted in our forums:

Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:

Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:

News »

Sony introduces the digital camera ZV-1 for content creators
Posted 27-May-2020 12:47

Samsung Announces 2020 QLED TV Range
Posted 20-May-2020 16:29

D-Link A/NZ launches AI-Powered body temperature measuring system
Posted 20-May-2020 16:22

NortonLifeLock Online Banking Protection now available for New Zealand banks
Posted 20-May-2020 16:14

SD Express delivers new gigabyte speeds for SD memory cards
Posted 20-May-2020 15:00

D-Link A/NZ launches Nuclias cloud managed network solution hosted in Australia
Posted 11-May-2020 17:53

Logitech introduces new video streaming solution for home studios
Posted 11-May-2020 17:48

Next generation Volvo cars to be powered by Luminar LiDAR technology
Posted 7-May-2020 13:56

D-Link A/NZ launches Wi-Fi Certified EasyMesh system
Posted 7-May-2020 13:51

Spark teams up with Microsoft to bring Xbox All Access to New Zealand
Posted 7-May-2020 13:01

Microsoft plans to establish its first datacenter region in New Zealand
Posted 6-May-2020 11:35

Genesis School-gen has joined forces with Mind Lab Kids
Posted 1-May-2020 12:53

Malwarebytes expands into privacy with fast, frictionless VPN
Posted 30-Apr-2020 16:06

Kordia to donate TV airtime on Channel 200 to community groups
Posted 30-Apr-2020 16:00

OPPO A91 is a high specs mid-range smartphone
Posted 23-Apr-2020 16:44

Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.

Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron

Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.