SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Bulk Insert


Bulk Insert

Author
Message
scott.barnett
scott.barnett
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 6
Hi All -

What I am looking to do is use a Bulk Insert to import a cvs file to a table. This table is for zip code rates (tax's based on zip codes). When do so using this code:

Bulk insert ziptaxrate
from 'C:\ziptest.csv'
with
(fieldterminator = ',',
rowterminator = '')

GO

I then get the following error:

Msg 4864, Level 16, State 1, Line 1
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 3 (TaxClassID).

This is the table build (also attached) :

USE [Store1]
GO
/****** Object: Table [dbo].[ZipTaxRate] Script Date: 06/09/2014 09:39:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ZipTaxRate](
[ZipTaxID] [int] IDENTITY(1,1) NOT NULL,
[ZipCode] [nvarchar](10) NOT NULL,
[TaxClassID] [int] NOT NULL CONSTRAINT [DF_ZipTaxRate_TaxClassID] DEFAULT ((1)),
[TaxRate] [money] NULL,
[CreatedOn] [datetime] NOT NULL CONSTRAINT [DF_ZipTaxRate_CreatedOn] DEFAULT (getdate()),
CONSTRAINT [PK_ZipTaxRate] PRIMARY KEY CLUSTERED
(
[ZipTaxID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]


Attached are screen shots also and the csv test file.

Any help would be great.
Attachments
Zip rate Screen shots.docx (3 views, 439.00 KB)
zip.txt (6 views, 700 bytes)
ziptest.xlsx (5 views, 9.00 KB)
Ed Wagner
Ed Wagner
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16552 Visits: 10059
It isn't necessary to post in more than one forum. It just duplicates effort for those helping and fragments any answers you get.
Direct replies to http://www.sqlservercentral.com/Forums/Topic1579175-148-1.aspx


Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search