Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Bulk Insert Expand / Collapse
Author
Message
Posted Tuesday, June 10, 2014 7:12 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, June 10, 2014 8:51 AM
Points: 3, Visits: 3
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.


  Post Attachments 
Zip rate Screen shots.docx (0 views, 439.73 KB)
zip.txt (2 views, 700 bytes)
ziptest.xlsx (2 views, 9.04 KB)
Post #1579170
Posted Tuesday, June 10, 2014 7:16 AM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 9:37 AM
Points: 4,346, Visits: 3,397
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
Post #1579178
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse