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
63613 posts

Uber Geek
+1 received by user: 14086

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 »

Xero announces new smarter tools, push into the North American market
Posted 19-Jun-2019 17:20

New report by Unisys shows New Zealanders want action by social platform companies and police to monitor social media sites
Posted 19-Jun-2019 17:09

ASB adds Google Pay option to contactless payments
Posted 19-Jun-2019 17:05

New Zealand PC Market declines on the back of high channel inventory, IDC reports
Posted 18-Jun-2019 17:35

Air New Zealand uses drones to inspect aircraft
Posted 17-Jun-2019 15:39

TCL Electronics launches its first-ever 8K TV
Posted 17-Jun-2019 15:18

E-scooter share scheme launches in Wellington
Posted 17-Jun-2019 12:34

Anyone can broadcast with Kordia Pop Up TV
Posted 13-Jun-2019 10:51

Volvo and Uber present production vehicle ready for self-driving
Posted 13-Jun-2019 10:47

100,000 customers connected to fibre broadband network through Enable
Posted 13-Jun-2019 10:35

5G uptake even faster than expected
Posted 12-Jun-2019 10:01

Xbox showcases 60 anticipated games
Posted 10-Jun-2019 20:24

Trend Micro Turns Public Hotspots into Secure Networks with WiFi Protection for Mobile Devices
Posted 5-Jun-2019 13:24

Bold UK spinoff for beauty software company Flossie
Posted 2-Jun-2019 14:10

Amazon Introduces Echo Show 5
Posted 1-Jun-2019 15:32

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.