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

Uber Geek
+1 received by user: 13846

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 »

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 »

HPE to acquire supercomputing leader Cray
Posted 20-May-2019 11:07

Techweek starting around NZ today
Posted 20-May-2019 09:52

Porirua City Council first to adopt new council software solution Datascape
Posted 15-May-2019 12:00

New survey provides insight into schools' technology challenges and plans
Posted 15-May-2019 09:30

Apple Music now available on Alexa devices in Australia and New Zealand
Posted 15-May-2019 09:11

Make a stand against cyberbullying this Pink Shirt Day
Posted 14-May-2019 20:23

Samsung first TV manufacturer to launch the Apple TV App and Airplay 2
Posted 14-May-2019 20:11

Vodafone New Zealand sold
Posted 14-May-2019 07:25

Kordia boosts cloud performance with locally-hosted Microsoft Azure ExpressRoute
Posted 8-May-2019 10:25

Microsoft Azure ExpressRoute in New Zealand opens up faster, more secure internet for Kiwi businesses
Posted 8-May-2019 09:39

Vocus Communications to deliver Microsoft Azure Cloud Solutions through Azure ExpressRoute
Posted 8-May-2019 09:25

Independent NZ feature film #statusPending to premiere during WLG-X
Posted 6-May-2019 22:13

The ultimate dog photoshoot with Nokia 9 PureView #ForgottenDogsofInstagram
Posted 6-May-2019 09:41

Nokia 9 PureView available in New Zealand
Posted 6-May-2019 09:06

Motorola Solutions joins local partners to deliver advanced communications network in New Zealand
Posted 30-Apr-2019 21:50

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.