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
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 BCP special characters issue

Author  Topic 

bhushan.panchabhai
Starting Member

1 Post

Posted - 2008-08-07 : 11:53:15
Hi,



I am trying to upload file which contains characters from different languages like french, chinese, turkish, greek etc. to database using bcp.



This is my table ->
CREATE TABLE [dbo].[Emp](
[EmpID] [int] NOT NULL,
[EmpName] [nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]


This is my file to upload->

asagi 1
anotheruser 2
user3 3

(Notice that EmpName appears before EmpID in input file.)
This is my format file ->

9.0
2
1 SQLNCHAR 0 800 "\t\0" 2 EmpName SQL_Latin1_General_CP1_CI_AS
2 SQLINT 0 12 "\r\0" 1 EmpID ""

When I run command ->
bcp database1.dbo.Emp in c:\EmpData.txt -f c:\EmpFMT.fmt -S dbserver -U sa -P pass

This is what I get in database ->
EmpID EmpName
852017 ?asagi

Unicode characters are preserved but,
There are following issues ->
1. I get only one record instead of all three.
2. inserted record has wrong EmpID. (EmpID is NOT identity/primary key)

I wonder whats going wrong here.
Please help.

   

- Advertisement -