1

I'm new to SQL Server and I want to bulk insert any data. This is the table in the database:

CREATE TABLE [dbo].[MARKAZ2]
(
    [id] [bigint] IDENTITY(1,1) NOT NULL,
    [city] [nvarchar](max) NULL,
    [center] [nvarchar](max) NULL,
    [copcity] [nchar](10) NULL,
    [start_tel] [nchar](20) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

and this is bulk format file:

12.0
4
1   SQLNCHAR 0  10  ";" 1   code        SQL_Latin1_General_CP1_CI_AS  
2   SQLNCHAR 0  40  ";" 2   city        SQL_Latin1_General_CP1_CI_AS 
3   SQLNCHAR 0  40  ";" 3   center      SQL_Latin1_General_CP1_CI_AS 
4   SQLNCHAR 0  40  ";" 4   copcity     SQL_Latin1_General_CP1_CI_AS 

but when I run this query:

BULK INSERT [ClubEatc].[dbo].[MARKAZ2]
    FROM 'd:\newmarkaz.csv'
    WITH (FORMATFILE = 'd:\behi.Fmt')

I get this error:

Msg 4863, Level 16, State 1, Line 4
Bulk load data conversion error (truncation) for row 1, column 1 (id).
Msg 7399, Level 16, State 1, Line 4
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 4
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".

What happened? How can I solve this? Thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
behzad razzaqi
  • 275
  • 2
  • 8
  • 23
  • Your have a identity field, this post may help: http://stackoverflow.com/questions/7063501/how-to-turn-identity-insert-on-and-off-using-sql-server-2008 – Prisoner Sep 19 '16 at 07:32
  • @Alex ok i delete identity field,now get the this error:Bulk load data conversion error (truncation) for row 1, column 1 (city). – behzad razzaqi Sep 19 '16 at 07:48
  • You specify `10` for size change value to `255`. – gofr1 Sep 19 '16 at 08:47

0 Answers0