Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 bulk insert problem, int not recognized

Author  Topic 

dainova
Starting Member

31 Posts

Posted - 2012-11-15 : 01:32:33
Hi, I'm running simple bulk insert and having this problem with setup like below


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Tmsg] ( --ESEventlogMain1](
[msgnumber] [int] NULL,
[msgttype] [int] NULL,
[mmsg] [varchar] (20) NULL
) ON [PRIMARY]


---------------------------testx.txt
11111;2;The status for service
22222;2;Host ADM104 (ADM Group)
33333;2;The status for service
---------------------------
BULK INSERT Tmsg FROM 'C:\Users\memb1\testx.txt'
WITH (FIELDTERMINATOR = ';', rowterminator = '\n')

--------------------------
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 1 (msgnumber).
---------------------------
select * from tmsg
msgnumber msgttype mmsg
----------- ----------- ----------------------------------------
22222 2 Host ADM104 (ADM Group)
33333 2 The status for service
[/code]
---
What is wrong, I did play with all /n/r, nothing helped, I'm on W and SQLExpress2008 Express.
Thanks for you help

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2012-11-15 : 03:23:02
Try with [mmsg] [varchar] (200) NULL instead

- Lumbago
My blog-> http://thefirstsql.com
Go to Top of Page

dainova
Starting Member

31 Posts

Posted - 2012-11-15 : 09:22:03
Tx, Lumbago. I tried this, same result
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2012-11-15 : 09:42:11
What is the code page of the file you are importing? If you don't know you can open it in NotePad++ (a free tool EVERYBODY should use) and it will say the code page in the bottom right corner.

- Lumbago
My blog-> http://thefirstsql.com
Go to Top of Page
   

- Advertisement -