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 2008 Forums
 Transact-SQL (2008)
 BULK INSERT with latin/chinese/japanese characters

Author  Topic 

vgarzon
Starting Member

11 Posts

Posted - 2010-03-17 : 19:35:25
Hi all,

I have an issue with a bulk insert that I did for loading a text file into a MS SQL table.

The T-SQL script is summarizes to:


DECLARE @OppFilePath varchar(64),
@report nvarchar(32),
@SQL_Ins varchar(2000)

-- Path to the directory where the files should be loaded
SET @OppFilePath = 'E:\Solution\XYZ\'

SET @report = (SELECT repWWW FROM tbl_WWW)

SET @SQL_Ins = 'BULK INSERT dbo.tbl_OpABC
FROM ' + CHAR(39) + @OppFilePath + @report + CHAR(39) + ' WITH (
DATAFILETYPE = ' + CHAR(39) + 'widechar' + CHAR(39) + ',
FIELDTERMINATOR = ' + CHAR(39) + '","' + CHAR(39) + ',
ROWTERMINATOR = ' + CHAR(39) + '\n' + CHAR(39) + ',
FIRSTROW = 2
)'
-- Bulk insert the file into the Opportunity Details table
EXEC sp_sqlexec @SQL_Ins


The txt file can have, in the second column, names in english, chinese, japanese, etc. So I need my table to write the record as it should (latin characters for wertern languages, other character sets for eastern languages)

The field that stores that information is nvarchar(max). I've tryes to save te text files as unicode, utf-8 and unicode big endian.

I don't know what I'm missing or if I need to retrieve the stored data with a special parameter on the select query to view the chinese and japanese kanjis and the latin letters. I can only see the latin letters right (english, spanish, portuguese, etc).

Any ideas?

Thanks in advance

vgarzon
Starting Member

11 Posts

Posted - 2010-03-18 : 12:08:24
Hey,

The issue was solved!.... It was the simplest, most ridiculous solution but when you're stuck you don't see it....

It was just to install the files for eastern languages on Windows... (For XP: Control Panel/Regional/Languages tab)

That solved the issue.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-03-18 : 12:27:28
Thanks for posting back with the solution. Maybe it will help someone else in the future.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -